Shell command real-combat detailed

Source: Internet
Author: User

1, according to a specified section of the path, the data copy.

= head Assembly.txt /ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbarabpei-119/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbcrabpei-135/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbdraapei- -/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbfrabpei-126/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbgrabpei-127/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbhrabpei-138/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbiraapei- -/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbjraapei- -/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustbkraapei- the/e3/gap/e3.scafseq_200/ifs1/st_env/user/liyiyuan/liushanlin/1kite_1_2/110817_i809_fcd05cdacxx_l3_insbustblraapei- the/e3/gap/e3.scafseq_200

Synchronous copying of #在当前目录把liushanlin/down data according to the original relative path

Cat assembly.txt|  while read i;  Do ' liushanlin/ ' ' {print $} ' ' /[^/]*$ ' ' {print $} ' " finished: $i \t$b " >>rsync.log;done

2. Parse path get file name and directory name

Get file name

#awk解法: Use "/" to make the delimiter, then print out the last part.

" / " ' {print $NF} "'

#官方解法 (basename): The Bash shell itself provides the basename command to get the file name of the pathname directly.

Resfile= ' Basename/tmp/csdn/zhengyi/test/adb.log '

Get directory Name

#awk解法: You can use the flexible delimiter to mix regular expressions.

' /[^/]*$ ' ' {print $} "'
Method of #awk +for cycle
' begin{res= ""; fs= "/";} {for (i=2;i<=nf-1;i++) res= (res "/" $i);} End{print res}'

#官方解法 (basename): The Bash shell itself provides the dirname command, which is especially handy to get the directory name of the path directly.

Dirpath= ' Dirname/tmp/csdn/zhengyi/test/adb.log '

Shell command real-combat detailed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.