Printing lines with specific awk NF


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Printing lines with specific awk NF
# 1  
Old 03-13-2007
Printing lines with specific awk NF

I have this files:
./frm/lf_mt1_cd.Ic_cell_template.attr
./die/addgen_tb_pumd.Ic_cell_template.attr
./min_m1_n.Ic_cell_template.attr

When I use:
awk -F\/ '{print NF}'

Would result to:
3
3
2

I would like to list the files with 3 fields on it. Any Suggestions?
# 2  
Old 03-13-2007
Explanation required

Just use
Code:
awk -F\/ 'NF == 3' filename

Please format what you type using the tags available. It will be more readable.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - printing new lines based of 2 dates

I have some test data that is seperated out into annual records, each record has a start date (COL7), an end date (COL8) and a maturity date (COL18) - What I need to do is ensure that there is one record to cover each year right up until Maturity date (COL18). In the first group of the below... (10 Replies)
Discussion started by: Ads89
10 Replies

2. Shell Programming and Scripting

Printing multiple lines on the same line between specific text

This is an extract from a large file. The lines that start with fc are ports on a fabric switch. In between each fc port there is information about the port. fc2/12 is up Port description is SEIEDISCOVER-3 Speed is 4 Gbps fc2/13 is down (Administratively down) fc2/14 is up Port... (1 Reply)
Discussion started by: kieranfoley
1 Replies

3. UNIX for Dummies Questions & Answers

Printing lines with specific strings at specific columns

Hi I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Discussion started by: a_bahreini
3 Replies

4. Shell Programming and Scripting

Printing next two lines from a file after grepping a specific pattern

Hi I have a file like # vi require.txt 1,BANK,Read blocks that cycle. yellow Read blocks. 2,ACCOUNT,Finished Red Finished . 3,LOAN, pipe white pipe 4,PROFIT,Resolve. black Resolve Am using like cat require.txt | grep -w ACCOUNTThe output I get is (8 Replies)
Discussion started by: Priya Amaresh
8 Replies

5. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

6. Shell Programming and Scripting

Help With AWK Matching and Re-printing Lines

Hi All, I'm looking to use AWK to pattern match lines in XML file - Example patten for below sample would be /^<apple>/ The sample I wrote out is very basic compared to what I am actually working with but it will get me started I would like to keep the matched line(s) unchanged but have them... (4 Replies)
Discussion started by: rhoderidge
4 Replies

7. Shell Programming and Scripting

Printing all lines before a specific string and a custom message 2 lines after

Hello all, I need to print all the lines before a specific string and print a custom message 2 lines after that. So far I have managed to print everything up the string, inclusively, but I can't figure out how to print the 2 lines after that and the custom message. My code thus far is:... (4 Replies)
Discussion started by: SEinT
4 Replies

8. Shell Programming and Scripting

Printing several lines of a file after a specific expression

Hello, I want to print a number of lines of a file after a specific expression of a line. I have this sed command but it prints only 1 line after the expression. How could I adapt it to print for instance 10 lines after or 15 lines after ? sed -n '/regexp/{n;p;}' Thx & Regs, Rany. (5 Replies)
Discussion started by: rany1
5 Replies

9. Shell Programming and Scripting

printing two lines in awk as two columns in excel

hi guys, i would like to print two lines from a file as two adjacent columns using excel using awk.. i have this so far: awk '{for(i=1; i<=NF; i++) {printf("%s\n",$i)}}' "$count".ttt > "$count".csv #this to print the first line from the .ttt file as rows of the first column in the .csv... (9 Replies)
Discussion started by: npatwardhan
9 Replies

10. Shell Programming and Scripting

Printing a specific line using AWK

Hi, I have a script that fetches only specific information from fcinfo command. Below is a portion of the script. #!/usr/bin/ksh set -x HBA_COUNT=`sudo fcinfo hba-port | grep -i state | awk 'END{print NR}'` echo "$HBA_COUNT HBAs exist" echo '........' INDEX=1 while $INDEX -le... (2 Replies)
Discussion started by: jake_won
2 Replies
Login or Register to Ask a Question