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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-30-2006
Registered User
 

Join Date: Apr 2006
Posts: 33
Parsing a file in Shell Script

Hi,

I have a requirement. I have an application which can take a file as inputs. Now the file can contain any number of lines. The tool has to pick up the first uncommented line and begin processing it.
For example the file could be like this:
#MANI123|MANI1234
#MANI234|MANI247
SENDIL204|SENDIL505
INPUT4|INPUT5.

Now the tool has to pick up only the third line as it is the first uncommented line i.e . SENDIL204|SENDIL505. How can I do this in a shell script

Thanks in advance
Sponsored Links
  #2 (permalink)  
Old 11-30-2006
Technorati Master
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 3,007

Code:
grep -v ^# filename

the logical first line becomes your actual first line
  #3 (permalink)  
Old 11-30-2006
Registered User
 

Join Date: Jul 2006
Posts: 189
use

grep -v "^\#" tmp

you can pipe this output to while loop and then process accordingly
  #4 (permalink)  
Old 11-30-2006
Technorati Master
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 3,007
Quote:
grep -v "^\#" tmp
What is the need for "^\#" ?

Just "^#" would do.
  #5 (permalink)  
Old 11-30-2006
Registered User
 

Join Date: Jul 2006
Posts: 189
i have not tried to rectify your post

i tried in my way
Sponsored Links
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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
parsing a string in a shell script asutoshch Shell Programming and Scripting 19 05-26-2008 10:18 PM
shell script parsing with sed jjamd64 UNIX for Dummies Questions & Answers 5 12-11-2007 04:51 PM
Parsing a line in Shell Script unishiva Shell Programming and Scripting 3 11-01-2007 04:30 PM
Help in parsing a CSV file with Shell script mihirk Shell Programming and Scripting 10 06-24-2007 11:58 AM
Shell script for parsing 300mb log file.. gurpreet470 Shell Programming and Scripting 3 02-09-2007 04:38 AM



All times are GMT -4. The time now is 06:34 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0