📄 ex42.sh
字号:
#!/bin/bash# copydir.sh# Copy (verbose) all files in current directory ($PWD)#+ to directory specified on command line.E_NOARGS=65if [ -z "$1" ] # Exit if no argument given.then echo "Usage: `basename $0` directory-to-copy-to" exit $E_NOARGSfi ls . | xargs -i -t cp ./{} $1# ^^ ^^ ^^# -t is "verbose" (output command line to stderr) option.# -i is "replace strings" option.# {} is a placeholder for output text.# This is similar to the use of a curly bracket pair in "find."## List the files in current directory (ls .),#+ pass the output of "ls" as arguments to "xargs" (-i -t options),#+ then copy (cp) these arguments ({}) to new directory ($1). ## The net result is the exact equivalent of#+ cp * $1#+ unless any of the filenames has embedded "whitespace" characters.exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -