1. COMMAND-LINE Options The command-line syntax fortop consists of: -hv|-bcHiOSs -d secs -n max -u|U user -p pid -o fld -w [cols] The typically mandatory switch('-') andeven whitespace are completely optional. -h | -v :Help/Version Show library version andthe usage prompt, then quit. -b :Batch-mode operation Starts top in Batch mode, which could be useful forsending output from top to other programs orto a file. In this mode, top will not accept input andruns until the iterations limit you've set with the `-n' command-line option oruntil killed. -c :Command-line/Program-name toggle Starts top with the last remembered `c' state reversed. Thus, iftop was displaying command lines, now that field will show program names, andvisa versa. See the `c' interactive command foradditional information. -d :Delay-time interval as: -d ss.t (secs.tenths) Specifies the delay between screen updates, andoverrides the corresponding value in one's personal configuration file orthe startup default. Later this can be changed with the `d' or`s' interactive commands. Fractional seconds are honored, but a negative number is not allowed. In all cases, however, such changes are prohibited iftop is running in Secure mode, except forroot (unless the `s' command-line option was used). For additional information on Secure mode see topic 6a. SYSTEM Configuration File. -H :Threads-mode operation Instructs top to display individual threads. Without this command-line option a summation of all threads in each process is shown. Later this can be changed with the `H' interactive command. -i :Idle-process toggle Starts top with the last remembered `i' state reversed. When this toggle is Off, tasks that have not used any CPU since the last update will not be displayed. For additional information regarding this toggle see topic 4c. TASK AREA Commands, SIZE. -n :Number-of-iterations limit as: -n number Specifies the maximum number of iterations, orframes, top should produce before ending. -o :Override-sort-field as: -o fieldname Specifies the name of the field on which tasks will be sorted, independent of what is reflected in the configuration file. You can prepend a `+' or`-' to the field name to also override the sort direction. A leading `+' will force sorting high to low, whereas a `-' will ensure a low to high ordering. This option exists primarily to support automated/scripted batch mode operation. -O :Output-field-names This option acts asa form of help forthe above -o option. It will cause top to printeach of the available field names on a separate line, then quit. Such names are subject to nls translation. -p :Monitor-PIDs mode as: -pN1 -pN2 ... or-pN1,N2,N3 ... Monitor only processes with specified process IDs. This option can be given up to 20 times, oryou can provide a comma delimited list with up to 20 pids. Co-mingling both approaches is permitted. A pid value of zero will be treated asthe process id of the top program itself once it is running. This is a command-line option only andshould you wish to returnto normal operation, it is not necessary to quit andrestart top -- just issue any of these interactive commands: `=', `u' or`U'. The `p', `u' and`U' command-line options are mutually exclusive. -s :Secure-mode operation Starts top with secure mode forced, even forroot. This mode is far better controlled through the system configuration file (see topic 6. FILES). -S :Cumulative-time toggle Starts top with the last remembered `S' state reversed. When Cumulative time mode is On, each process is listed with the cpu time that it andits dead children have used. See the `S' interactive command foradditional information regarding this mode. -u | -U :User-filter-mode as: -u | -U number orname Display only processes with a user id oruser name matching that given. The `-u' option matches on effective user whereas the `-U' option matches on any user (real, effective, saved, orfilesystem). Prepending an exclamation point ('!') to the user id orname instructs top to display only processes with users not matching the one provided. The `p', `u' and`U' command-line options are mutually exclusive. -w :Output-width-override as: -w [ number ] In Batch mode, when used without an argument top will format output using the COLUMNS= andLINES= environment variables, ifset. Otherwise, width will be fixed at the maximum 512 columns. With an argument, output width can be decreased orincreased (up to 512) but the number of rows is considered unlimited. In normal display mode, when used without an argument top will attempt to format output using the COLUMNS= andLINES= environment variables, ifset. With an argument, output width can only be decreased, not increased. Whether using environment vari‐ ables oran argument with -w, when not in Batch mode actual terminal dimensions can never be exceeded. Note: Without the useof this command-line option, output width is always based on the terminal at which top was invoked whether ornot in Batch mode.
#!/bin/bash ddl_file_path=/c/Users/user/Downloads/sqoop_data/hive_2_mysql ls $ddl_file_path| whileread f;doecho "--------->"$ddl_file_path/$f## Template#sed -i 's///g' $ddl_file_path/$f#sed -i "s///g" $ddl_file_path/$f sed -i 's/111.111.111.111:3306/222.222.222.222:3307/g' $ddl_file_path/$fsed -i "s/'password_1'/'password_2'/g" $ddl_file_path/$f done # echo -e "=========>\n\t Files contains keyword "/WARN:" in path $ddl_file_path are deleted!!!"
登录后复制
1
#!/bin/bash set -x ## Template#sed -i 's///g' $ddl_file_path/$f#sed -i "s///g" $ddl_file_path/$f ## Func 1 - 实现在所有文件的第四行、第五行插入指定文本 ddl_file_path=/e/迅雷下载/user_data_after ls $ddl_file_path | while read f;do # 如果文件不是文件夹类型,才允许插入操作 if [ ! -d $f ];then echo "--------->"$ddl_file_path/$f sed -i '4i retries=10' $ddl_file_path/$f sed -i '5i retry.backoff=3' $ddl_file_path/$f fidone ## Func 2 - 如果文件夹不存在,则创建;反之提示文件已存在 if [ ! -d "beijing" ];then mkdir beijingelse echo "File already exists"fi
登录后复制
文件类型的参数判别大全:
1
shell脚本判断文件类型 shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/"myFile="/var/log/httpd/access.log"# 这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if[ ! -x "$myPath"]; then mkdir"$myPath"fi # 这里的-d 参数判断$myPath是否存在 if[ ! -d "$myPath"]; then mkdir"$myPath"fi # 这里的-f参数判断$myFile是否存在 if[ ! -f "$myFile"]; then touch "$myFile"fi # 其他参数还有-n,-n是判断一个变量是否是否有值 if[ ! -n "$myVar"]; then echo"$myVar is empty"exit0 fi # 两个变量判断是否相等 if[ "$var1"= "$var2"]; then echo'$var1eq $var2' elseecho'$var1not eq $var2' fi
登录后复制
文件的判别逻辑大全:
1
-a file exists. -b file exists andis a block special file. -c file exists andis a character special file. -d file exists andis a directory. -e file exists (just the same as-a). -f file exists andis a regular file. -g file exists andhas its setgid(2) bit set. -G file exists andhas the same group ID asthis process. -k file exists andhas its sticky bit set. -L file exists andis a symbolic link. -n string length is not zero. -o Named option is set on. -O file exists andis owned by the user ID of this process. -p file exists andis a first in, first out (FIFO) special file ornamed pipe. -r file exists andis readable by the current process. -s file exists andhas a size greater than zero. -S file exists andis a socket. -t file descriptor number fildes is open andassociated with a terminal device. -u file exists andhas its setuid(2) bit set. -w file exists andis writable by the current process. -x file exists andis executable by the current process. -z string length is zero. 注意-s 和 -f 参数的区别