bash script to remove first characters from every line
I downloaded bazaar.txt for a shell scripting-pdf, so that I can follow the examples I want to get rid of the margin (there are two spaces in front of every line. I've tried
sed '/^ /!d' bazaar.txt | tr -s ' ' > bazaar2.txt but this will only remove one space, one more to go:) using the same method btw does not work twice. Hints, links, information and flames all appreciated. |
To cut off a range of characters you can do:
Code:
cut -b 1-2 --complement bazaar.txt |
It Works!
-It's funny, I'm doing this so I have a file to work with to learn shell-scripting(shell-scripting.pdf)...and to get passed the 'sed' and 'tr' lessons, 'cut' would have been next! Anyway thanks texmex
|
sed 's/^ *//' file > newfile
Removes any number of spaces at the beginning of the line |
Example files
HI
I'm also trying to wade throught the shellscripting.pdf book but am unable to find the files it refers to in the examples. Both the bazaar.txt and emails{1,2,3}.txt. COuld you tell me where you obtained them from? |
Download
Hi,
Can you please let me know where to download the files listed in shell-scripting.pdf? http://www.catb.org/~esr/writings/cathedral-bazaar/ does not work. I also not able to download other files, emails1.txt, emails2.txt emails3.txt columns.txt telnum.txt. I would really appreciate if someone can tell me where to get these files. Thanks, Mak |
Remove specific beginning character
I'm trying to combine two text files and remove common phrases in each file. I've done that with
'comm -3 text1.txt text2.txt > new.txt' But it puts them in columns so I have a column for text1 and a column for text2 so I did 'comm -3 --output-delimiter=0 text1.txt text2.txt > new.txt' but now I have 0's in front of text2 phrases. I was wondering if there was anything I could && or | to, to remove the 0's or maybe even a better way of doing this. I would greatly appreciate any nudges in the right direction. |
Try using 'uniq -u' instead.
|
Thank you
I ended up using
Code:
cat ~/txtfolder/* |sort|uniq|less > new.txt |
All times are GMT -5. The time now is 07:02 PM. |