Blog
Delete list of available files from one directory to another directory on linux (RHEL / Fedora / Centos )
Let us see how to list available files on any directory
ls/
bash script to remove the available files from directory in current directory.
$ for file in `ls directory`; do rm -rf $file; done
Example,
[ ~\home\testing]$ for file in `ls dir1`; do rm -rf $file; done
In this example, deletes the available files from dir1 in current directory '~/home/testing/'
bash script to copy the available files from directory to another directory.
$ for file in `ls directory1`; do cp -rf $file directory2; done
Example,
[ ~\home\testing]$ for file in `ls dir1`; do cp -rf $file dir2; done
In this example, deletes the available files from directory dir1 to directory dir2.
« Previous Next » Blog
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page