Results 1 to 2 of 2
Basically, I'm quite new to writing BASH scripts, as you'll soon see.
The script below that I'm trying to write has the sole purpose of taking the current filename, and ...
- 12-09-2008 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 3
Bash Script Going wrong :(
Basically, I'm quite new to writing BASH scripts, as you'll soon see.
The script below that I'm trying to write has the sole purpose of taking the current filename, and renaming it to the Absolute Path + filename.
Example:
File Name Path
EGFilename.txt 07007879/work/
The file is renamed and becomes:
becomes "07007879/work/EGFilename.txt"
-----
What my file is actually doing....
Error//
DelScript.txt: line 11: /home/07007879/work: is a directory
mv: missing destination file operand after `tube.txt'
///
My Script:
Code:echo $"Do you want to delete a file 0/1?" read answer while [ $answer -eq 0 ] do echo $"Enter Filename and Extension" read filename echo $filename DIR=$(cd "$DIR" && pwd && cd $OLDPWD) fin=$("$DIR" && "$filename") mv $filename $fin echo $"The file" $filename "was removed" echo $"Do you want to delete another file? 0/1" read answer done
Does anyone have any solutions?
Please put everything as lamen terms as possible, quite new
Thanks!
- 12-10-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
The main problem seems to be that "&&" does not do string concatenation. You can simply say "${var1}${var2}" to concatenate the values of two variables. Furthermore, the last argument of "mv" may be a directory, so you don't need to create the filename.


Reply With Quote