[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: scripts

John Summerfied wrote:
Les Mikesell wrote:

On Thu, 2006-03-02 at 14:18, azeem ahmad wrote:

hi list
i got some scripts. their behavior is much wierd, they dont execute, when i run them they say
bad interpreter
and if i open them and copy them into a new file which i create using vi then the same script executes.
it seems to be a problem of encoding like ASCII etc
can i change them using any tools
any suggestions

They were probably created under windows and transferred over
with carriage-return, line-feed endings intact.  If you
load them into vim, type :set fileformat=unix and save
again it should fix them.  Or use the dos2unix program.

There's a magic perl incantation you can recite. Or you can
 cat olddir/script | tr -d '\r' >newdir/script
for all and at the end
 chmod +x newdir/*

A quicker way with vim:
for $f in olddir/* ; do vim -c ':set fileformat=unix' -c :wq $f ; donw

Any more ways to change this light bulb?

How about:

sed -i -e 's/\r//' script


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]