Re: [UNIX NEWBIE] - scripting help

From: Invincibill (bill@longboys.net)
Date: 02/12/99


you sure about that? it looks to me like erics solutions will do every
file in the directory. its piping the output from the ls command into
gawk, which strips the carriage return then redirects its output into
a temp file. it then renames the temp file to the original file.

i might recommend tho, that you rename the temp file as the original
file into a different directory. just in case.(you dont really need to
tho. if your arent paranoid)

if you make sure that you have only text files(ie source code) in the
directory you run this is, it should work fine.

i dont have much experience with awk however, so you may be right. in
which case, i apologize. but this is cool. i guess i'll have to do some
playing around with it.

"Mark A. Heilpern" wrote:
>
> What Eric presented was an alternative to your dos2unix tool, not a way
> to handle an entire directory. How you script a mass conversion is
> based on the shell you use. As long as you've got bash in /bin/bash,
> try:
>
> #!/bin/bash
> for filename in *.c; do
>   dos2unix $filename >_tmp_file
>   mv _tmp_file $filename
> done
> #--------- end of the script. make the script executable!
>
> You'll note I didn't rename the file to have a k on the end, I just
> made it more simple since it's a temp file only.
>
> At 11:02 AM 2/12/99 -0600, you wrote:
> >try something like....
> >
> >/bin/ls -1 | gawk '{system("tr -d \"\\015\" < "$1" > "$1".tmp");system("mv
> >"$1".tmp "$1);}'
> >
> >Eric
> >
> >> dos2unix act.comm.c > act.comm.ck
> >> mv act.comm.ck act.comm.c
> >> dos2unix ban.c > ban.ck
> >> mv ban.ck ban.c
> >> etc etc...
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
>      +------------------------------------------------------------+

--
Weather forecast for today: Sunny & Mild
Weather forecast for tomorrow : Sunny & Mild
www.giftsgalore.com : www.longboys.net
telnet://undying.longboys.net:4000 http://undying.longboys.net


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST