On Fri, Sep 16, 2011 at 12:47:11AM +0800, lina wrote: > > > You have options. > > Just some additional remarks: > > a) the for-loop won't work, as "FILE" is expanded to the name including > > the .txt, so if you have a file "a.txt" this loop will execute > > mv a.txt.txt a.txt.pdf > > You need instead > > for FILE in *.txt; do mv $FILE `basename $FILE .txt`.pdf; done > > in order to remove the ".txt" from the variable "$FILE" > > > > Seriously, I have problem testing this one, > > the come out is like: > > (basename $FILE .txt.pdf > > sorry I might be so sleepy, I will check another time, You probably typed a mixture with the solution from Aaron :-) I think the opening parenthesis "(" CAN'T stem from my line -- there should be no "(" In fact, I use just a different syntax then Aaron to achieve the same result: We want to evaluate the command "basename $FILE .txt" and pass the output of this command as argument to mv (this feature is called "command substitution" in the man-page). Now, there are two ways to achieve this in bash: 1) use $(...) 2) use `...` There are only some minor difference how a backslash is treated within $(...) and `...`.
Axel -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20110915170104.GI2798@axel