In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the shell recursive function how to circularly copy files to the designated directory, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Code:
#! / bin/shrecursive () {for file in $1 do subfile= `ls $2 $3 then rm $file` for subsubfile in $subfile do # echo $subsubfile if ["$subsubfile" = = "$2 $3/$file"] then rm-rf $3/$file mv $subsubfile $3/$file else recursive `ls $2 $3Compact $file` $2 $3/$file Fi done done} cd / tmpmkdir update;tar-zxvf update.tgz-C update;chmod-R 755 / tmp/update/*;rootdir= "/ tmp/update" filelist= `ls / tmp/update/ `for file in $filelistdo subfile= `ls $rootdir/$ file`for subsubfile in $subfile do if ["$subsubfile"! = "$rootdir/$file"] then $(recursive `ls $rootdir/$ file` $rootdir/$file) # rm-rf / $file/$subfile # mv $rootdir/$file/$subsubfile / $file break 1 Else kill-9 `ps | grep $file` rm-f / usr/bin/$file mv $rootdir/$file / usr/bin fi donedone#reboot
The following are new additions
Create soft links to all files in the folder, and linked files can be specified to be saved to other directories
When you assign a filelist, you can specify the source path
In the following sentence "ln-s $file arm-linux-" $lastwd ", you can specify the directory of the linked file, for example, the source path is the current path, and the destination path is also the current path.
# / bin/bash
Filelist= `ls. / `
For file in $filelist
Do
Firstwd=$file | cut-d "-"-F1
# if ["$firstwd" = = "arm"]
# then
Lastwd= `echo "$file" | sed's Unip. Sed-[] $/\ 1Unip'`
Echo $lastwd
Ln-s $file arm-linux- "$lastwd"
# fi
Done
Thank you for reading this article carefully. I hope the article "how to circularly copy files to a specified directory in shell" shared by the editor is helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.