I have a problem with being able to echo a part of a string.
Here is a simplified version:
I want to echo no_1187985 only so:
tt=$(echo $t | cut -d":" -f 1) echo $tt
But this produces just a blank space (and a command no found error in my actual script)
If I changed -f 1 to - f 2, it works for the second field, I don't understand why not the first.
Here is a portion of my actual code for context:
while read line; do #echo $line #sleep 1 path=$(dirname "$line") #echo $path #mkdir -p $(echo $path | cut -d":" -f 2) inode= $(echo $path | cut -d":" -f 1) echo $inode #mv ~/deleted/$inode $(echo $line | cut -d":" -f 2); done < .temp
This is an attempt to create a recyclebin .temp is a file with the pathnames of different files to 'restore'. the loop looks through each line. It recreates the directory tree before moving the files back into them. the files are currently stored in the deleted folder and have their inode number attached to the end. When the file is 'restored' (i.e moved back), the inode is removed from the filename .
the .temp file contains the file name (the original and inode combined) and the original pathname both are separated by a ":" delimiter.