[expert] Need a script to rename a file
Hello all, My shell script takes a jpeg file as the input like this: myscript test.jpg. After some processing I then create an empty file in a subdirectory named text like this: touch ../text/$1. The question is, how do I replace the suffix jpg with txt? In this case I want to end up with a file called test.txt. My initial efforts have centred around sed s/jpg/txt/ and mv but without success. -- Regards, Phil [EMAIL PROTECTED] Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] Need a script to rename a file
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Am Sonntag, 1. September 2002 10:16 schrieb Phil: Hello all, My shell script takes a jpeg file as the input like this: myscript test.jpg. After some processing I then create an empty file in a subdirectory named text like this: touch ../text/$1. The question is, how do I replace the suffix jpg with txt? In this case I want to end up with a file called test.txt. My initial efforts have centred around sed s/jpg/txt/ and mv but without success. either try filename=`echo $1 | grep sed s/jpg/txt/g` or filename=`basename $1 .jpg` if $1 is your filename to handle. Martin - -- - H E L I X Gesellschaft für Software Engineering mbH - Hanauer Landstrasse 52 Telefon (069) 4789 35-30 60314 Frankfurt am Main Telefax (069) 4789 35-44 - http://www.helix-gmbh.net[EMAIL PROTECTED] - -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9czsTBG198cnayKQRAuiVAJ0XoXOgcISv83T6Cn3F13e9d73omgCfTRoS 98tq0xNtkyBL/anvy1+oQ94= =Vw8T -END PGP SIGNATURE- Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] Need a script to rename a file
On Sun, 1 Sep 2002 09:16:01 +0100 Phil [EMAIL PROTECTED] wrote: Hello all, My shell script takes a jpeg file as the input like this: myscript test.jpg. After some processing I then create an empty file in a subdirectory named text like this: touch ../text/$1. The question is, how do I replace the suffix jpg with txt? In this case I want to end up with a file called test.txt. My initial efforts have centred around sed s/jpg/txt/ and mv but without success. -- Regards, Phil [EMAIL PROTECTED] touch ../text/$(basename $1 .jpg).txt bye jipe Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com