-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'll give it a go in the morning.

sed -i is not dangerous... unless you didn't make a copy of the data
first...

Mark Carlson wrote:
> On 10/17/06, Gustin Johnson <[EMAIL PROTECTED]> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> I have a client who has mysteriously damaged a whole bunch of files.
>> Basically, there are 2300 files in a directory and sub-directories,
>> which are comma  delimited.  Somehow a bunch of files had an extra comma
>> added at the end of some lines.  What I need to do is to remove double
>> commas ",," from the _end_ of some lines in each file (there are double
>> commas in the middle of the line that must be untouched).
>>
>> This screams sed  to me, but I am missing something, since I cannot seem
>> to find the regex incantation that will find two commas at the end only.
>>
>> It seemed simple, but then I am used to vim syntax (:%s/,,$/,/g), which
>> normally also works in sed for me.
>>
>> Any help would be appreciated.
> 
> -bash-2.05b$ cat > test.txt
> test1,,
> test2,,
> test3,,test4,,
> 
> -bash-2.05b$ cat test.txt | sed "s/,,$/,/"
> test1,
> test2,
> test3,,test4,
> 
> 
> 
> That works here...
> 
> of course, it isn't writing it back to the file in this case.
> 
> If you want to play with fire, you can do: `sed -i "" -e "s/,,$/,/" files`
> 
> This will edit files in place without making a backup (replace
> brackets with an extension to make a backup of each file)
> 
> Dunno about recursing into directories, might need to pair `sed` with
> `find` for that.
> 
> _______________________________________________
> clug-talk mailing list
> [email protected]
> http://clug.ca/mailman/listinfo/clug-talk_clug.ca
> Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
> **Please remove these lines when replying
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFNbc0wRXgH3rKGfMRAt3TAJ4wkne9zYxdZyf/26j2zwigdhI/PACgoGsn
qGU7Mfj73RPkhPs/7uf8RzE=
=tARZ
-----END PGP SIGNATURE-----

_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying

Reply via email to