delete first 2 characters for each line, please help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete first 2 characters for each line, please help
# 1  
Old 02-10-2012
delete first 2 characters for each line, please help

hi,

./R1_970330_210505.sard
./R1_970403_223412.sard
./R1_970626_115235.sard
./R1_970626_214344.sard
./R1_970716_234214.sard
...
...
...

for these strings, i wanna remove the ./ for each line
how can i do that?

i know it could possibly be done by sed, but i really have not idea how to use that command

thanks a lot!
# 2  
Old 02-10-2012
You don't need sed for such a simple task:
Code:
cut -c3- file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 02-10-2012
For completeness, here is the sed command:
Code:
sed 's/..//' file

This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 02-11-2012
AWK one
Code:
awk -F"/" '{print $2}' urfile


Last edited by Franklin52; 02-11-2012 at 11:45 AM.. Reason: Please use code tags for data and code samples, thank you
# 5  
Old 02-11-2012
sed only ..

Code:
  
[root@SKS Shirish]# echo "123 shirish" > a
[root@SKS Shirish]# cat a
123 shirish
[root@SKS Shirish]#  sed -i 's/^.\{2\}//g'   a
[root@SKS Shirish]# cat a
3 shirish
[root@SKS Shirish]#

Hope It will help u bit ...

FOR YOUR CONTENT ...

Code:
[root@SKS Shirish]# cat ab
./R1_970330_210505.sard
./R1_970403_223412.sard
./R1_970626_115235.sard
./R1_970626_214344.sard
./R1_970716_234214.sard
[root@SKS Shirish]# sed -i 's/^.\{2\}//g' ab
[root@SKS Shirish]# cat ab
R1_970330_210505.sard
R1_970403_223412.sard
R1_970626_115235.sard
R1_970626_214344.sard
R1_970716_234214.sard
[root@SKS Shirish]#

--Shirish Shukla

Last edited by Shirishlnx; 02-11-2012 at 12:38 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete special characters

My sed is not working on deleting the entire special characters and leaving what is necessary.grep connections_per a|sed -e 's/\<\!\-\-//g' INPUT: <!-- <connections_per_instance>1</connections_per_instance> --> <method>HALF</method> <!--... (10 Replies)
Discussion started by: kenshinhimura
10 Replies

2. Shell Programming and Scripting

Remove first 2 characters and last two characters of each line

here's what im trying to do. i have a file containing lines similar to this: data.txt: 1hsRmRsbHRiSFZNTTA1dlEyMWFkbU5wUW5CSlIyeDFTVU5SYjJOSFRuWmpia0ZuWXpKV2FHTnRU 1lKUnpWMldrZFZaMG95V25oYQpSelEyWTBka2QyRklhSHBrUjA1b1kwUkJkd3BOVXpWM1lVaG5k... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. Programming

Mismatched free() / delete / delete [] line no missing

Could you tell me the possibilities of the reason to get the Mismatched free() / delete / delete . I unable to see the line no in the valgrind report. it displays the function name. with that function name, I am not able to find where exactly the issue is there.I am getting the Mismatched free()... (3 Replies)
Discussion started by: SA_Palani
3 Replies

4. Shell Programming and Scripting

Delete and retain some characters

Ive been trying to google and tried sed and awk. BUt still getting no exact formula. I would like to know how to parse this at: From: Compute Machin Appliance 3.2.9.10000 123456 To: Compute Machin Appliance 3.2.9.123456 (5 Replies)
Discussion started by: kenshinhimura
5 Replies

5. UNIX for Dummies Questions & Answers

How to delete text between two characters in line?

Hi, I have a large text file with the following format: >gi|347545744|gb|JN204951.1| Dismorphia spio voucher 5 ATCAAATTCCTTCCTCTCCTTAAA >gi|17544664774|gb|WN204922.32| Rodapara nigens gene region CCGGGCAAATTCCTTCCTCTCCTTAAA >gi|555466400|gb|SG255122.8| Bombyx mandariana genbank 3... (1 Reply)
Discussion started by: euspilapteryx
1 Replies

6. Shell Programming and Scripting

How delete characters of specific line with sed?

Hi, I have a text file with some lines like this: /MEDIA/DISK1/23568742.MOV /MEDIA/DISK1/87456321.AVI /MEDIA/DISK2/PART1/45753131.AVI /IMPORT/44452.WAV ... I want to remove the last 12 characters in each line that it ends "AVI". Should look like this: /MEDIA/DISK1/23568742.MOV... (12 Replies)
Discussion started by: inaki
12 Replies

7. Shell Programming and Scripting

Delete characters from each line until meet character ":"

Hello, I have file that looks like this : 765327564:line1 94:line2 7865:line3 ..... 765322:linen I want to cut all the digits from the beginning of each line up to ":" character and to have everything like this : line1 line2 line3 ..... linen P.S : content of line1 ...... (8 Replies)
Discussion started by: black_fender
8 Replies

8. Shell Programming and Scripting

Delete characters from each line

Hi, I have a file that has data in the following manner, tt_0.00001.dat 123.000 tt_0.00002.dat 124.000 tt_0.00002.dat 125.000 This is consistent for all the entries in the file. I want to delete the 'tt_' and '.dat' from each line. Could anyone please guide me how to do this using awk or... (2 Replies)
Discussion started by: lost.identity
2 Replies

9. Shell Programming and Scripting

Delete new line characters from a file

Hi, I have a file with about 25 colums separated with '~', but few of the lines have extra tabs ('^') and new line characters ('$'). Is there a way I can delete those characters if they are anywhere before the 25th column in a line? example: CLUB000650;12345678;0087788667;NOOP MEMBER ... (4 Replies)
Discussion started by: rudoraj
4 Replies

10. Shell Programming and Scripting

delete duplicated characters in each line

I'm a biologist trying to analyse some data and I'll appreciate some help with the following problem. I have a column of characters which I'll like to delete the duplicated characters in each line and report only the unique one.No sorting should be done. E.g. The original data: GTG CTC CTC... (5 Replies)
Discussion started by: ivpz
5 Replies
Login or Register to Ask a Question