Questions tagged [nawk]

`nawk` is a pattern scanning and processing language.

A nawk program is a sequence of patterns and corresponding actions.

The string specifying program must be enclosed in single quotes (') to protect it from interpretation by the shell.

The sequence of pattern - action statements can be specified in the command line as program or in one, or more, file(s) specified by the -f progfile option.

When input is read that matches a pattern, the action associated with the pattern is performed.

125 questions
1
vote
1 answer

Nawk Commmad in Unix

I have a nawk command as shown. Can anyone explain what this command is suppose to do. set sampFile = $cur_dir/${qtr}.SAMP nawk -F "," '{OFS=","; if (($4 == "0000" || $4 == "00000000")) {print $0} }' $samp_input_file >! $sampFile
gautam vegeta
  • 653
  • 6
  • 13
  • 28
1
vote
4 answers

Linux: Extract and transform attributes from line

if got a file, with lines in the following format: SOME_ATTRIBUTE_1 XYZ; IMPORTANT_ATTRIBUTE_1 1234; SOME_ATTRIBUTE_2 XYZ; IMPORTANT_ATTRIBUTE_2 AB; Now I want to transform this into the following form, that the two important attribute values…
Franz Kafka
  • 10,623
  • 20
  • 93
  • 149
1
vote
1 answer

Getting error in substituting special characters with sed/perl

I am trying to substitute few special characters using sed/perl for which I am getting errors. In below command i am trying to replace values for SEARCHFIELDAPP, OLD_STRING,NEW_STRING etc; Server1> SERVER_COMMAND="perl -F'\|' -i -lape 'if (\$F[0]…
Chkusi
  • 139
  • 1
  • 5
  • 15
1
vote
1 answer

Want to edit a file in place (substitute a column value) based on a value in another column in the same file

I want to edit a file in place (substitute a column value) based on a value in another column in same file. I don't want to redirect the output after substitution to another file but rather would want to edit the file in place. Specifically need…
Chkusi
  • 139
  • 1
  • 5
  • 15
1
vote
1 answer

Splitting of files based on a criteria

I have a file with below data .domain bag .set bag1 bag1 abc1 .set bag2 bag2 abc2 .domain cat .set bag1:cat bag1:cat abc1:cat .set bag2:cat bag2:cat abc2:cat I want to split this file into two (bag1.txt and bag2.txt) based on the set…
Vijay
  • 65,327
  • 90
  • 227
  • 319
1
vote
1 answer

Fancy awk output without using printf

This is just for curiosity. I have a tab delimited file like this jklh banana hk hkl klh jklh h hk banana h hk kljh asdf banana lk sdfa jklæ jklæ banana sdf jklæ By doing this I replace 'banana' in the first column and the…
AWE
  • 4,045
  • 9
  • 33
  • 42
0
votes
1 answer

How to print specific column in row wise using unix?

I have one input file which is given…
gyrous
  • 189
  • 3
  • 6
  • 19
0
votes
2 answers

Missing header in awk output

input: position fst 1 0.6 2 0.8 3 0.9 4 0.3 5 1 This gives me a header: awk '{if ($2>=0.7) print $1}' input > output but this doesn't: awk '{if ($2<0.7) print $1}' input > output How come?
AWE
  • 4,045
  • 9
  • 33
  • 42
0
votes
3 answers

I would like to have the difference between 2 files. Want to find specifically at what column the difference has occured using Unix Scripting

We are doing a data migration project migrating from Informix to Oracle. Now a requirement has come up to compare the data between Informix and oracle tables. So Table1 from Informix will be migrated to Table1 in Oracle. Now data is migrated from…
Chkusi
  • 139
  • 1
  • 5
  • 15
0
votes
1 answer

shell scripts - "nawk"

Hi i ve been trying to read records from a final_customer_total.txt which contains details like size of processed files. I used "nawk" command to read the final_customer_total.txt to calculate total size processed and then store the total sum into…
prabhakar
  • 55
  • 1
  • 6
0
votes
4 answers

How to get the lines from a file where a particular string is repeating more than once in each line?

I have a file like below (an example file). 10,Bob,elec,Bob,hero,, 20,Bob,mech,steve,juni,,,yumm 30,Bob,instr,Bob,sen 40,Bob,comps,alex,juni,syu,, 50,Bob,chem,Bob,Bob,seni I would need all lines where string Bob is appearing more than once in each…
Chkusi
  • 139
  • 1
  • 5
  • 15
0
votes
2 answers

how do i match a space with two shell variables inside awk in just one match function

I have a command: ls -l | nawk -v d1=Sep -v d2=26 '{if(match($0,d1)) print $0}' -rw-rw-r-- 1 nobody nobody 12 Sep 26 11:36 file1 -rw-rw-r-- 1 nobody nobody 14 Sep 26 11:37 file2 -rw-rw-r-- 1 nobody nobody 0 Sep 26…
Vijay
  • 65,327
  • 90
  • 227
  • 319
0
votes
3 answers

UNIX shell script and escaping quotes for AWK script

I have a UNIX script that has nawk block inside it (This is just a part of the UNIX and NAWK script. It has many more logic and the below code should definitely be in nawk) This block that reads a lookup value for Country ISO code from a file that…
user549432
  • 137
  • 2
  • 8
  • 20
0
votes
2 answers

Search for a number in each line of a string in ksh and nawk

The input file: vnic10 e1000g1 e1000g2 vnic10 blablabla888blablablabla999blabla Output needed:(Only the numbers in each line) 10 1000 1 1000 2 10 888 999 We can do this using sed and remembered patterns. I am looking for the logic to get this done…
tomkaith13
  • 1,717
  • 4
  • 27
  • 39
0
votes
2 answers

Pull lines from log file between two strings with a third string inbetween

I'm looking for a command line way (on SunOS) to pull from a log file xml messages which contain a particular string. For example, the log file might contain xml messages of the form: uniqueId="123456"
EdMan888
  • 3
  • 1
1 2 3
8 9