How to Select or cut from the certain filed to the end of the line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Select or cut from the certain filed to the end of the line
# 1  
Old 04-10-2008
How to Select or cut from the certain filed to the end of the line

Hi:

I have few rows in file..Like suppose...
9063C0 44 00051363603253033253347 3333 070248 06
9063C0 5G PAN00013
9063C0 44 00061030305040404250724 0506 100248 08
9063C0 43 01 00000089

I need to cut the row starting after "9063C0" till the end of the line and store in another file...

My o/P is:
44 00051363603253033253347 3333 070248 06
5G PAN00013
44 00061030305040404250724 0506 100248 08
43 01 00000089
# 2  
Old 04-10-2008
CPU & Memory Use grep and sed combination

Hi Rajesh,


Use grep and sed combinations to do the need.

grep ^9063C0 test | sed 's/^9063C0//'
where test is the file name.

OUTPUT :
===========
$> grep ^9063C0 test
9063C0 44 00051363603253033253347 3333 070248 06
9063C0 5G PAN00013
9063C0 44 00061030305040404250724 0506 100248 08
9063C0 43 01 00000089


$> grep ^9063C0 test | sed 's/^9063C0//'
44 00051363603253033253347 3333 070248 06
5G PAN00013
44 00061030305040404250724 0506 100248 08
43 01 00000089


Hope this is what u wanted......

Last edited by helper; 04-10-2008 at 07:20 AM..
# 3  
Old 04-10-2008
Hi Rajesh,


Use grep and sed combinations to do the need.

grep "9063C0" test | sed 's/9063C0//'
where test is the file name.

OUTPUT :
===========
$> grep ^9063C0 test
9063C0 44 00051363603253033253347 3333 070248 06
9063C0 5G PAN00013
9063C0 44 00061030305040404250724 0506 100248 08
9063C0 43 01 00000089


$> grep ^9063C0 test | sed 's/9063C0//'
44 00051363603253033253347 3333 070248 06
5G PAN00013
44 00061030305040404250724 0506 100248 08
43 01 00000089


Hope this is what u wanted......
# 4  
Old 04-10-2008
Code:
awk '{ $1=""; print }' file

# 5  
Old 04-10-2008
Code:
cut -d" " -f 2- test

# 6  
Old 04-10-2008
Thankx all... Its working.........
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut the strings from end

could you please help me. I have below autosys jobs 01_enable_input_hol_dtpz1b 01_abc_copy_ld_sat_xxxz1 01_abc_mavcd_yyyyyxxxz1 01_abcdef_oa_xxxxxz1 01_fdgte_symbol_ddddz1 01_fsdfsd_clean_mmmhhhfz1 01_fsdfd_create_mut_marchtz1 I want to remove name after last "_" underscore so that... (6 Replies)
Discussion started by: sdosanjh
6 Replies

2. Shell Programming and Scripting

Replace first field of a line with previous filed of the line

Hi Everyone, I have a file as below: IM2345638,sherfvf,usha,30 IM384940374,deiufbd,usha,30 IM323763822,cdejdkdnbds,theju,15 0,dhejdncbfd,us,20 IM398202038,dhekjdkdld,tj,30 0,foifsjd,u2,40 The output i need is as below IM2345638,sherfvf,usha,30... (4 Replies)
Discussion started by: usha rao
4 Replies

3. Shell Programming and Scripting

Cut line from file till the end

Hi I have a 57 line text file and I want to cut first 6 line assigned it to a veriable and again cut next 6 line assigned to same variable till the time file have left 0 line. Please let me know how I can do in scripting. Thanks Sanjay (6 Replies)
Discussion started by: Sanjay2121
6 Replies

4. Shell Programming and Scripting

delete to end of formatted warnings using sed or cut...

hi, i've searched the forums' entries and have tried some of the examples -- to no avial -- this is my first post -- thanks in advance for your help... As part of an installation program -- i'm receiving two(2) extraneous "libcxb WARNING!" statements -- i want to use sed to eliminate the... (12 Replies)
Discussion started by: rickkar
12 Replies

5. Shell Programming and Scripting

cut but include delimiter at end

Can someone please tell me how to do this... input file - /etc/group: wheel:*:0:root,timber daemon:*:1: mysql:*:88: ...etc... giants:*:1001:dalton,bandit dalton:*:1002: bandit:*:1003: output file (my goal): giants:*:1001: dalton:*:1002: bandit:*:1003:I've come up with this: ... (3 Replies)
Discussion started by: Lewcifer
3 Replies

6. Shell Programming and Scripting

cut from a particular character to the end of the string

Hi All, I have a string like "9633C01302_2". I need to extract the number(02) after "13" and before "_" and the number coming after "13" and before "_" is not constant, it keeps on changing... Can some one plz help me wth the command.. i tried this echo "9633C01302_2" | cut -d'_' -f1 ..But... (2 Replies)
Discussion started by: grajesh_955
2 Replies

7. Shell Programming and Scripting

To cut end string from line

HI, I want to cut end string from line. e.g. i have following input line /users/home/test.txt I want to get end string 'test.txt' from above line and length of that end string will change and it always start after '/'. Thanks, Visu (7 Replies)
Discussion started by: visu
7 Replies

8. Shell Programming and Scripting

Select matches between line number and end of file?

Hi Guys/Gals, I have a log file that is updated once every few seconds and I am looking for a way to speed up one of my scripts. Basically what I am trying to do is grep through a text file from start to finish once. Then each subsequent grep starts at the last line of the previous grep to... (4 Replies)
Discussion started by: Jerrad
4 Replies
Login or Register to Ask a Question