Shell Scripting
Been sat here for hours now trying to get a shell script working using awk. Still can't do it :( Its basically a very primitive undelete script. If a user uses a del script (e.g. del mytempfile) that has been written, the file is renamed into a number (the number depends on the number of previously deleted files!) and then moved into $HOME/recycle-bin.
An index file in the recycle bin folder records the new file name and path along with the original file name e.g. (3 home/kid/mytempfile) so over a period of time you end up with an index file looking like
1 /home/file
2 /home/file2
3 /home/new_file
4 /home/next_file
5 /home/another_file_name
6 /home/file4
If the user wants to restore one of their old files they simply type undel [filename]. The difficulty which i'm having at the moment is passing the users input (e.g. the [filename]) as a variable into awk that finds matching files. I understand you use the $1 (to get the first argument after undel) but no matter how i go about it, i can't get that value into awk :( Any ideas how??
An index file in the recycle bin folder records the new file name and path along with the original file name e.g. (3 home/kid/mytempfile) so over a period of time you end up with an index file looking like
1 /home/file
2 /home/file2
3 /home/new_file
4 /home/next_file
5 /home/another_file_name
6 /home/file4
If the user wants to restore one of their old files they simply type undel [filename]. The difficulty which i'm having at the moment is passing the users input (e.g. the [filename]) as a variable into awk that finds matching files. I understand you use the $1 (to get the first argument after undel) but no matter how i go about it, i can't get that value into awk :( Any ideas how??
