LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Shell substitute regexp

[ILUG] Shell substitute regexp

Chris Higgins <chris.higgins> chris.higgins at horizon.ie
Tue Jul 24 12:03:36 IST 2001


> Bleargh...  basename(1), my friend, basename(1):
> 
>    for i in *.dat ; do mv $i `basename $i .dat` ; done

Bloody hell - where do you get off giving simple straight forward solutions
to problems - this is supposed to be Unix ... you didn't even have one
regexp in your solution.. Pah..

And you did it in one line as well... pathetic..

What you really want to do is :-

ls -l > 1.txt
vi 1.txt

Change each line where it has 
-rw-r--r--    1 chris    staff     2577338 Jul 22 22:28 pres.sdc
to
mv pres.sdc pres

Then add 
 #!/bin/sh
to the top of the file..

Then exit from vi
:q!

Then realising that you didn't save the file, start from scratch.
exit vi this time using 
:wq

Now, you have a script to change all your file names for you.

Then 
./1.txt

When it complains that it's not executable, try
chmod +x 1.txt

and then

./1.txt


And presto chango - all your files will change name for you.


See - no messing with silly things like basename... next thing you'll
be telling people about dirname

> 
> Later,
> Kenn
> 
> 
> -- 
> Irish Linux Users' Group: ilug at linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at linux.ie

-- 
** Chris Higgins                         e: chris.higgins at horizon.ie **
** Technical Business Development        tel: +353-1-6204916            **
** Horizon Technology Group              fax: +353-1-6204949            **

-- 
** Chris Higgins                         e: chris.higgins at horizon.ie **
** Technical Business Development        tel: +353-1-6204916            **
** Horizon Technology Group              fax: +353-1-6204949            **






More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell