How to filter files by month to move to a specified folder under linux
Linux how to filter files by month to move to the specified folder, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
Vi fun.sh
#! / bin/sh
# mkdir 201807
# find all the file names of the Jul under the specified folder, and do not search for subdirectories
Filelist=$ (ls-al / sx/logfiles/ | grep "^ -" | grep 'Jul' | awk-F'' {print $9}')
# move files to the specified folder
For i in $filelist
Do
Mv $I / 201807
Done
: wq
# sh fun.sh
Ps:
# find files in the current directory that are earlier than one day ago, and move to the specified folder.
# find. /-mtime + 1-exec mv {} / tmp\
Sometimes an error may be reported during compilation, perhaps because there is something wrong with the default compilation environment.
Under Ubuntu, you need to switch the compilation environment, for example:
# bash fun.sh
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.