Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save thanoojgithub/2b586af7bb45ad95ba70c65f51a00e16 to your computer and use it in GitHub Desktop.

Select an option

Save thanoojgithub/2b586af7bb45ad95ba70c65f51a00e16 to your computer and use it in GitHub Desktop.
How to delete files listed in a text file
pwd
current_pwd=`pwd`
cd /home/thanooj/work
pwd
ls -ltr
for f in $(cat /home/thanooj/files/symlink_localized_file_list.txt); do
rm "$f"
done
ls -ltr
cd $current_pwd
ls -ltr
pwd
NOTE:
For removing directories recursively and forcefully:
rm -rf "$f"
If those file are symbolic link - remove symbolic link:
unlink "$f"
Creating symbolic link:
ln -s /home/thanooj/files/dailycached.txt /home/thanooj/files/dailycached_symbolic_link.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment