LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-21-2006, 08:33 AM   #1
thedarkdestroyer
LQ Newbie
 
Registered: Mar 2006
Posts: 7

Rep: Reputation: 0
Removing Characters when outputting to a script


Hi, i have this script that creates another script which lists all duplicate files and give the user an option to uncomment the line to allow it to remove the files, the script is as follows:

#############################
OUTF=henderson.sh;
echo "#! /bin/sh" > $OUTF;
find "$@" -type f -print0 |
xargs -0 -n1 md5sum |
sort --key=1,32 | uniq -w 32 -d --all-repeated=separate |
sed -r 's/^[0-9a-f]*( )*//;s/([^a-zA-Z0-9./_-])/\\\1/g;s/(.+)/#rm \1/' >> $OUTF;
chmod a+x $OUTF; ls -l $OUTF
#############################

the output looks like this:

#! /bin/sh
#rm \ \ ./.kde/share/fonts/fonts.dir
#rm \ \ ./.kde/share/fonts/overide/fonts.dir


but i need it to remove the \ \ ./. so that the output looks like this:

#! /bin/sh
#rm kde/share/fonts/fonts.dir
#rm kde/share/fonts/overide/fonts.dir

Anyone any ideas?

Thanks
 
Old 03-21-2006, 09:52 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,397
Blog Entries: 1

Rep: Reputation: 64
Strange...I'm not getting theses double back slashes...

Code:
miguel@gold:~/tmp> cat henderson.sh
#! /bin/sh
#rm ./motion-3.2.4/debian/motion.1
#rm ./motion-3.2.4/motion.1

#rm ./cron-4.1-20.src.rpm
#rm ./cron/cron-4.1-20.src.rpm

#rm ./motion-3.2.4/pwc-ioctl.h
#rm ./motion-3.2.4/pwc-ioctl.h-10.0.5
 
Old 03-21-2006, 09:57 AM   #3
thedarkdestroyer
LQ Newbie
 
Registered: Mar 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Even odder!! when i run this script on SuSE 9.1 it dosent work at all, im running it on Knoppix 4.0 and it works like i mentioned before, im using the sh shell, im pretty new to Linux/Unix/GNU+Linux..... do the shells in different versions compile differently, i though sh would be the same on Knoppix and SuSE
 
Old 03-21-2006, 04:13 PM   #4
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
maybe you have this problem (LC_ALL='C') :? ~> http://www.linuxquestions.org/questi...hreadid=327916
Quote:
After setting the environmental variable LC_ALL='C' grep behaves as expected. <SNIP>
use [[:upper:]] and [[:lower:]] in scripts.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script question: automatic \ of escape characters in string lagu2653 Programming 2 03-08-2006 08:58 AM
how to have no interpretation of special characters (ctrl, tab ...) in a script xround Linux - General 1 11-29-2004 08:21 AM
exploding string into individual characters using a shell script farmerjoe Programming 9 10-13-2004 04:23 AM
removing lines from file script iluvatar Programming 9 08-20-2004 06:49 AM
I need help removing a startup script kennyog Linux - Newbie 3 06-05-2004 10:18 PM


All times are GMT -5. The time now is 08:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration