The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to print lines till till a pattern is matched in loop anoopvraj Shell Programming and Scripting 3 10-30-2008 10:36 PM
Urgent Help required : awk/sed help to find pattern and delete till end of line rajan_san UNIX for Advanced & Expert Users 1 08-25-2008 06:18 PM
Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line rajan_san Shell Programming and Scripting 2 08-25-2008 05:53 PM
search for the matched pattern by tracing back from the line Sharmila_P Shell Programming and Scripting 9 08-04-2008 09:21 AM
sed remove last 10 characters of a line start from 3rd line minifish Shell Programming and Scripting 7 03-26-2008 04:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-18-2009
kiranlalka kiranlalka is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 11
Question Need to remove few characters from each line till a pattern is matched

Hi All,

I want to remove first few characthers from starting of the line till ',' Comma... which needs to be done for all the lines in the file

Eg:

File content

1,"1234",emp1,1234
2,"2345",emp2,2345

Expected output is

,"1234",emp1,1234
,"2345",emp2,2345

How can parse the file in the above manner using a shell scripts.. which command will be good to chose. How this can be achieved.
  #2 (permalink)  
Old 05-18-2009
durden_tyler's Avatar
durden_tyler durden_tyler is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2009
Posts: 551

Code:
sed 's/^[^,]*//' <file>

tyler_durden
  #3 (permalink)  
Old 05-18-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,342
Or:


Code:
sed 's/^.//' file

  #4 (permalink)  
Old 05-18-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
Quote:
Originally Posted by Franklin52 View Post
Or:


Code:
sed 's/^.//' file
may need to change to take care of more characters before the comma

@OP, awk

Code:
awk -F"," '{$1=""}1' OFS="," file

  #5 (permalink)  
Old 05-19-2009
kiranlalka kiranlalka is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 11
Thanks

I used the below code

Quote:
Originally Posted by durden_tyler View Post
Code:
sed 's/^[^,]*//' <file>

tyler_durden
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0