How can i create a simple bash script to cut out a small part (eg. a word) of a name of a file, the same word on several files?
In more detail, i have several files (of same extension), which start with
I'm assuming the program has to ask me for the common word, search a folder, display the files with the common word, and ask me to delete it...
I've managed to write up 2 functions to get the location and search for file names with that word respectively, but can't quite figure out how to delete that word from the file names...
# This is a trap, to catch signals
# particularely ctrl^c
trap 'echo "Force Quit."; exit 1' 2
# Ask for the directory
# Ask user for the location of the file
echo -n "Location of Directory (leave empty for current): "
# If no input then take default source location
if [ "$myLocation" = "" ]; then
pwd > location
echo "Location: $myLocation"
# Search for the word you want.
echo -n "Enter Word: "
echo "Files with '$myWord' are: "
ls $myLocation | grep $myWord
Note: default source location section doesn't work atm...
EDIT: heh.. apparently it *does* work =)