homepage Welcome to WebmasterWorld Guest from 54.227.11.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Re: Using a bash script to alter multiple files
Reply to an old thread
leifbk




msg:3359819
 9:14 am on Jun 6, 2007 (gmt 0)

While working on a similar problem, I stumbled upon this thread: [webmasterworld.com ]. As I'm not allowed to reply to that one as it's too old, I'll start a new one more or less for the record.

I did a little hack that does the requested job, using the '$@' bash variable. It will accept wildcard arguments on the command line, so you may run it on multiple files like "iso2utf8 *.php".

#! /bin/bash
# iso2utf8 - convert all specified files to utf-8

for FILE in `ls $@`
do
iconv -f iso-8859-1 -t utf-8 $FILE > tempfile.tmp
mv -f tempfile.tmp $FILE
ls -l $FILE
done

I hope that this may be of help to someone.

regards, Leif

[edited by: encyclo at 6:11 pm (utc) on June 6, 2007]
[edit reason] no signatures please [/edit]

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved