On Sat, 2007-09-15 at 12:57 +0530, Vikas Rawal wrote:
> > chars in Unix. I found the way to do it using vi, but couldnt find a way to
> > like do for a number of files all at once. Any solutions??
> 
> Following will work if ^ does not appear elsewhere in the file (other
> than with ^M at the end of each line).
> 
> cat filename | cut -d^ -f1 > filename
> 
> If ^ appears elsewhere also, a simple awk script will do the trick.

Ack. Not commenting on the script itself, but this is dangerous.
Depending on the shell, filename will be rewritten immediately
due to the '>' redirection, and thus this will end up making
the file blank. Also, Google for "Useless use of cat".

To run a well-behaved command, called say cmd, that reads
content from filename on standard input, does some processing
on the content, and rewrites it to the same filename, do
  cmd < filename > tmp.$$ && mv tmp.$$ filename

Regards,
Gora


_______________________________________________
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - September 28-29, 2007
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/

Reply via email to