All Questions

76
votes
7answers
45951 views

awk save modifications in place

I am learning awk and I would like to know if there is an option to write changes to file, similar to sed where I would use -i option to save modifications to a file. I do understand that I could us...
93
votes
9answers
26791 views

How to use multiple arguments for awk with a shebang (i.e. #!)?

I'd like to execute an gawk script with --re-interval using a shebang. The "naive" approach of #!/usr/bin/gawk --re-interval -f ... awk script goes here does not work, since gawk is called with th...
207
votes
23answers
321334 views

Using awk to print all columns from the nth to the last

right now I have this line, and it worked until I had whitespace in the second field. svn status | grep '\!' | gawk '{print $2;}' > removedProjs is there a way to have awk print everything in $2...
9
votes
9answers
15237 views

Parsing a CSV file using gawk

How do you parse a CSV file using gawk? Simply setting FS="," is not enough, as a quoted field with a comma inside will be treated as multiple fields. Example using FS="," which does not work: file...
126
votes
9answers
103009 views

Print second last column/field in awk

I want to print the second last column or field in awk. The number of fields is variable. I know that I should be able to use $NF but not sure how it can be used. And this does not seem to work: awk...
12
votes
5answers
53830 views

How to run an awk commands in windows?

I have downloaded gawk from here, but I can't seem to figure out how to use it. I am simply trying to run a command, not to write one.
2
votes
3answers
265 views

How to filter logs easily with awk?

Suppose I have a log file mylog like this: [01/Oct/2015:16:12:56 +0200] error number 1 [01/Oct/2015:17:12:56 +0200] error number 2 [01/Oct/2015:18:07:56 +0200] error number 3 [01/Oct/2015:18:12:56 +0...
5
votes
6answers
10604 views

Printing long integers in awk

I have a pipe delimited feed file which has several fields. Since I only need a few, I thought of using awk to capture them for my testing purposes. However, I noticed that printf changes the value if...
2
votes
4answers
8352 views

Print Field 'N' to End of Line

I would like to have help or direction on a problem I have in awk. I have a tab-delimited file with more than 5 fields. I want to output the fields excluding the first 5 fields. Could you please tel...
16
votes
2answers
13648 views

Print all Fields with AWK separated by OFS

Is there a way to print all records separated by the OFS without typing out each column number. #Desired style of syntax, undesired result [kbrandt@glade: ~] echo "1 2 3 4" | gawk 'BEGIN { OFS=" :-(...

Previous Next