Visit Our UNIX and Linux User Community

awk if statement matching all lines starting w/ a number

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk if statement matching all lines starting w/ a number
# 8  
Old 10-19-2009
Finally hit the jack pot. again thank you for your contribution which help me move forward along to my destination:

print $0
if ( $1 ~ /^#/ ) {
        print $0 }
if ( NF == 4 ){
    if ( system("test -d " $4) ) {
    else {
        print "1        0       0       "$4 "\n" }

---------- Post updated at 06:03 PM ---------- Previous update was at 05:29 PM ----------

n1djs & scottn finally hit the jack pot. Again thank you for your contribution which help me move forward along to my destination:

   print $0
if ( $1 ~ /^#/ ) {
   print $0 }
if ( NF == 4 ){
   if ( system("test -d " $4) ) {
   else {
        print "1        0       0       "$4 "\n" }

Previous Thread | Next Thread
Test Your Knowledge in Computers #888
Difficulty: Easy
sed was developed from 1973 to 1974 by Bill Gates of Microsoft.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

2. Shell Programming and Scripting

Select only the lines of a file starting with a field which is matcing a list. awk?

Hello I have a large file1 which has many events like "2014010420" and following lines under each event that start with text . It has this form: 2014010420 num --- --- num .... NTE num num --- num... EFA num num --- num ... LASW num num --- num... (9 Replies)
Discussion started by: phaethon
9 Replies

3. Shell Programming and Scripting

Matching and Replacing file lines starting with $

Here is the task that I was presented with: I am dealing with about a 10,000 line input deck file for an analysis. About 10 separate blocks of around 25 lines of code each need to be updated in the input deck. The input deck (deckToChange in the code below) comes with 2 separate files. File 1... (5 Replies)
Discussion started by: tiktak292
5 Replies

4. Shell Programming and Scripting

Compare two files and count number of matching lines

Dear All, I would like to compare two files and return the number of matches found. Example File A Lx2 L1_Mus1 L1Md_T Lx5 L1M2 L1_Mus3 Lx3_Mus Lx9 Lx2A L1Md_A L1Md_F2 File B L1_Mus3 L1_Mus3 (3 Replies)
Discussion started by: paolo.kunder
3 Replies

5. Shell Programming and Scripting

Awk, sed - concatenate lines starting with string

I have a file that looks like this: John Smith Marc Olsen Lynne Doe (3 Replies)
Discussion started by: locoroco
3 Replies

6. Solaris

awk - Print variable number of colums from a starting column

Hi guys, I usualy am able to google awk stuff but I can't find it so far and there are so many awking gurus here that I will give it a shot. I want to print $1;$3;"$5 up to the $NF". In other words, I can have 1000 colums, but need to have $5 up to the end. I started with the idea of... (2 Replies)
Discussion started by: plmachiavel
2 Replies

7. Emergency UNIX and Linux Support

Urgent help to extract two lines having same starting number

Hi , I have a huge file like this =245 this is testing =035 abc123 =245 this is testing1 =035 abc124 =245 this is testing2 =035 abc125 =035 abc126 =245 this is testing3 here i have to pull out those lines having two =035 instead of alternative 035 and 245 i.e extract... (18 Replies)
Discussion started by: umapearl
18 Replies

8. Shell Programming and Scripting

awk statement to match all lines starting with "#"

Looking for awk statement that will match all lines starting with "# " if ( $1 == \^"#" ) Input file: # of the server. If you would like to set these, please take out the # pound (#) sign in front of one or all severities and set it equal to # severity desired. For example, FATAL=3 #... (2 Replies)
Discussion started by: Arsenalman
2 Replies

9. Shell Programming and Scripting

How to print the number of lines from a file, the starting string should be passed`

Hi , I have file, which has the below content: line 100 a b c d line300 a s d f s line200 a s d a (3 Replies)
Discussion started by: little_wonder
3 Replies

10. Shell Programming and Scripting

How can I get an if statement to execute based on number of lines in a file?

I need to have an if statement in a script to run if there are certain processes running. Easiest way I can see to do this is to run a ps and grep the results based on what I am looking for: $ ps -ef | grep wtrs --- webtrend 5046 1 0 May 12 ? 0:28 /webtrends/versions/6.1/wtrs_ui... (6 Replies)
Discussion started by: LordJezo
6 Replies
is  a  text formatter.	Its input consists of the text to be out-
put, intermixed with formatting commands.  A  formatting  command
is  a  line  containing  the  control character followed by a two
character command name, and possibly one or more arguments.   The
control  character is initially . (dot).  The formatted output is
produced on standard output.  The formatting commands are  listed
below, with being a number, being a character, and being a title.
A + before n means it may be signed,  indicating  a  positive  or
negative change from the current value.  Initial values for where
relevant, are given in parentheses.
  .ad	  Adjust right margin.
  .ar	  Arabic page numbers.
  .br	  Line break.  Subsequent text will begin on a new line.
  .bl n   Insert n blank lines.
  .bp +n  Begin new page and number it n. No n means +1.
  .cc c   Control character is set to c.
  .ce n   Center the next n input lines.
  .de zz  Define a macro called zz. A line with .. ends definition.
  .ds	  Double space the output. Same as .ls 2.
  .ef t   Even page footer title is set to t.
  .eh t   Even page header title is set to t.
  .fi	  Begin filling output lines as full as possible.
  .fo t   Footer titles (even and odd) are set to t.
  .hc c   The character c (e.g., %) tells roff where hyphens are permitted.
  .he t   Header titles (even and odd) are set to t.
  .hx	  Header titles are suppressed.
  .hy n   Hyphenation is done if n is 1, suppressed if it is 0. Default is 1.
  .ig	  Ignore input lines until a line beginning with .. is found.
  .in n   Indent n spaces from the left margin; force line break.
  .ix n   Same as .in but continue filling output on current line.
  .li n   Literal text on next n lines.  Copy to output unmodified.
  .ll +n  Line length (including indent) is set to n (65).
  .ls +n  Line spacing: n (1) is 1 for single spacing, 2 for double, etc.
  .m1 n   Insert n (2) blank lines between top of page and header.
  .m2 n   Insert n (2) blank lines between header and start of text.
  .m3 n   Insert n (1) blank lines between end of text and footer.
  .m4 n   Insert n (3) blank lines between footer and end of page.
  .na	  No adjustment of the right margin.
  .ne n   Need n lines.  If fewer are left, go to next page.
  .nn +n  The next n output lines are not numbered.
  .n1	  Number output lines in left margin starting at 1.
  .n2 n   Number output lines starting at n.  If 0, stop numbering.
  .ni +n  Indent line numbers by n (0) spaces.
  .nf	  No more filling of lines.
  .nx f   Switch input to file f.
  .of t   Odd page footer title is set to t.
  .oh t   Odd page header title is set to t.
  .pa +n  Page adjust by n (1).  Same as .bp
  .pl +n  Paper length is n (66) lines.
  .po +n  Page offset.	Each line is started with n (0) spaces.
  .ro	  Page numbers are printed in Roman numerals.
  .sk n   Skip n pages (i.e., make them blank), starting with next one.
  .sp n   Insert n blank lines, except at top of page.
  .ss	  Single spacing.  Equivalent to .ls 1.
  .ta	  Set tab stops, e.g., .ta 9 17 25 33 41 49 57 65 73 (default).
  .tc c   Tabs are expanded into c.  Default is space.
  .ti n   Indent next line n spaces; then go back to previous indent.
  .tr ab  Translate a into b on output.
  .ul n   Underline the letters and numbers in the next n lines.

Featured Tech Videos