Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Extract information from file

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 15  
Old 05-15-2017
Quote:
Originally Posted by vedanta
Many thanks!
One problem I am seeing here is that awk also is reading the comment lines.
Is there a way to ignore all comment lines at the very beginning? Should I need to create a separate post for this? Thanks1
If you are having problems with comments in the shell scripts that are being fed into the script you specified in post #1 in this thread, you don't need to start a new thread; otherwise, you do.

Either way you need to explain what comments need to be removed and exactly how your awk script is supposed to determine what you consider to be a "comment line at the very beginning". The only comment shown in your sample input file(s) is:
Code:
#!/bin/ksh

and I don't see why removing that comment from your input files will make any difference in your results. If you don't supply representative sample input files corresponding to the data you want to process, you are wasting time for all of us.
# 16  
Old 05-15-2017
Quote:
Originally Posted by vedanta
Many thanks!
One problem I am seeing here is that awk also is reading the comment lines.
Is there a way to ignore all comment lines at the very beginning? Should I need to create a separate post for this? Thanks.


I have used below as a solution

added !/^#/ eg,
/pfile/ && !/^#/ { ..
Most easy: at the beginning of the awk script put
Code:
/^#/ { next }

It will skip the following code whenever a #comment is met.
# 17  
Old 05-15-2017
Quote:
Originally Posted by MadeInGermany
Most easy: at the beginning of the awk script put
Code:
/^#/ { next }

It will skip the following code whenever a #comment is met.
Note that it can't quite be at the beginning of the script... It has to come after:
Code:
awk ' NR==1 {
                        print "File      | Jobname |  node  | pfile               | metafile            | tname | priority | delay" # to be replaced by tab
                   }

or you won't get the desired heading line in your output file.
The Following User Says Thank You to Don Cragun For This Useful Post:
MadeInGermany (05-15-2017)
# 18  
Old 05-15-2017
Good point. The correct location is here
Code:
awk ' NR==1 { ...
  }
/^#/ { next }

Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract information from file jiam912 Shell Programming and Scripting 11 11-12-2016 01:06 AM
Extract information from txt file edekP Shell Programming and Scripting 11 11-09-2016 12:32 PM
How to extract information a file according key id in another file? the_simpsons Shell Programming and Scripting 11 08-18-2014 02:14 PM
How to extract information from a file? the_simpsons Shell Programming and Scripting 9 05-20-2014 05:47 PM
Extract various information from a log file SilvesterJ Shell Programming and Scripting 4 09-27-2011 12:00 PM
extract information from a log file (last days) matarsak Shell Programming and Scripting 14 09-19-2011 03:23 PM
Create shell script to extract unique information from one file to a new file. Mr_47 Shell Programming and Scripting 16 09-11-2011 01:33 PM
Extract information from Log file formatted dummie55 Shell Programming and Scripting 3 03-11-2011 02:30 PM
extract and format information from a file sujoy101 Shell Programming and Scripting 12 04-16-2008 06:58 AM
How to extract a piece of information from a huge file Marcor Shell Programming and Scripting 2 03-13-2008 04:33 PM


All times are GMT -4. The time now is 05:25 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password