Replace wc with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace wc with awk
# 1  
Old 02-27-2013
Replace wc with awk

Code:
awk 'FNR<='${linenum}' && /'"${SEC1}"'/ && /'"${SEC2}"'/' | wc -l

how can i use awk to count the lines instead of wc?
# 2  
Old 02-27-2013
Have a variable incremented on each match and in the END{} have it printed out. With 420 posts you should get along with this description Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies

2. UNIX for Beginners Questions & Answers

Replace using sed or awk

Hi, Need a help to replace a word if a pattern is found between the delimiters preferably using SED or AWK. below is the sample file that iam dealing with, need to match pattern 'application' if found replace the whole word between the delimiters and also print the lines that don't match.... (1 Reply)
Discussion started by: tech_frk
1 Replies

3. Shell Programming and Scripting

Find and Replace in awk

Friends, I have more the thousand lines like this. check.cloud1.port=342 check.cloud2.port=5456 check.cloud3.port-4564 But we need to transfer it to _CHECK.CLOUD1.PORT_=342 _CHECK.CLOUD2.PORT_=5456 _CHECK.CLOUD3.PORT_=4564 Any one could pls help of this. Thanks in Advance ... (1 Reply)
Discussion started by: jothi basu
1 Replies

4. UNIX for Dummies Questions & Answers

Replace substrings in awk

Hi ! my input looks like that: --AAA-AAAAAAA---------AA- AAA------AAAAAAAAAAAAAA ------A----AAAA-----A------- Using awk, I would need to replace only the "-" located between the last letter and the end of the string by "~" in order to get: --AAA-AAAAAAA---------AA~... (7 Replies)
Discussion started by: beca123456
7 Replies

5. Shell Programming and Scripting

replace in Awk

i have a file that has data like template.txt Version:V1.0 name:ACTION Number Of Actions:1 A:ACC,EVE,P1,1,1,ACC,2,ACC,3,1,5,20090228 10070800,6,20130628 10070800 now i have to replace all occurrence of ACC with a value and occurences of EVE with a value. my shell script is as below ... (3 Replies)
Discussion started by: niteesh_!7
3 Replies

6. Shell Programming and Scripting

replace using awk

Hi, I am trying to replace 4th and 5th column data with the below code awk -F, '$1=="ABC"&&$2=="XYZ" {gsub(/ABC/, "TEST" ,$4,$5)}' infile.txt > 1.txt if the first column data is ABC and second column data is XYZ then replace ABC to test in 4th and 5th column, the above code is replacing the... (1 Reply)
Discussion started by: shruthidwh
1 Replies

7. Shell Programming and Scripting

awk incremental replace

Hello! I have the following lines in a file: 1|0|HEADER| 2|1|HEADER| 3|1|MAIN| 4|1|INFO| 5|1|INFO| 6|1|INFO| 7|2|INFO| 8|4|INFO| 9|55|FOOTER| 10|1|HEADER| 11|22|MAIN| 12|9|MAIN| and I want to convert it into: (7 Replies)
Discussion started by: TasosARISFC
7 Replies

8. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

9. Shell Programming and Scripting

Sed help to replace and then awk

Sed help echo "(200 rows affected)" | sed -e '/\(//p' | sed -e '/\)//p' | awk '{print $1}' I want output as "200" Please help me correct (2 Replies)
Discussion started by: pinnacle
2 Replies

10. Shell Programming and Scripting

Need to replace text in an awk

Hey guys: Running Solaris 5.5.1 and trying to write an easy /bin/sh script. Here is what I am doing... grep "Total" /workspace_4/local/reports/cust_calls_5ess.050510 | awk '{print $4 "\t" $7 $8 $9 $10 $11 $12 $13 $14}' It renders the following results... 315268 ... (2 Replies)
Discussion started by: cdunavent
2 Replies
Login or Register to Ask a Question