
awk
List of commands for awk:
-
awk:ai:193be replace column with awk$ awk -F',' '{ $2 = "replacement_text" } 1' file.csvtry on your machineexplain this command
-
awk:ai:9a3ab Edit a file in place with awk by replacing 'pattern' with 'replacement'$ awk -i inplace '/pattern/{replacement}' filetry on your machineexplain this command
-
awk:ai:a3ddf format output file with awk$ awk -F "\t" 'BEGIN{print "{\"cli command\":\"${command}\", \"description\":\"${description}\"},"} {print "{\"cli command\":\""$1"\", \"description\":\""$2"\"},"}' input_file | awk 'NR>1{print p} {p=$0} END{printf "%s\n]", p}'try on your machineexplain this command
-
awk:ai:a64a1 Delete a single line from a given file with awk$ awk '!/pattern/' filename > newfiletry on your machineexplain this command
-
awk:ai:d3723 cut lines with awk$ awk 'BEGIN{ FS = "|" } { print $1 }' ${filename}try on your machineexplain this command
-
awk:ai:f75b1 How to edit a file with awk$ awk 'pattern { action }' filenametry on your machineexplain this command
-
awk:tldr:16f09 awk: Print different values based on conditions.$ awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' ${filename}try on your machineexplain this command
-
awk:tldr:39f5d awk: Print the fifth column (a.k.a. field) in a space-separated file.$ awk '{print $5}' ${filename}try on your machineexplain this command
-
awk:tldr:56083 awk: Sum the values in the first column of a file and print the total.$ awk '{s+=$1} END {print s}' ${filename}try on your machineexplain this command
-
awk:tldr:5662d awk: Print the last column of each line in a file, using a comma (instead of space) as a field separator.$ awk -F ',' '{print $NF}' ${filename}try on your machineexplain this command
-
awk:tldr:88dc4 awk: Print all the lines which the 10th column value is between a min and a max.$ awk '($10 >= min_value && $10 <= max_value)'try on your machineexplain this command
-
awk:tldr:89541 awk: Print every third line starting from the first line.$ awk 'NR%3==1' ${filename}try on your machineexplain this command
-
awk:tldr:aea97 awk: Print all lines where the 10th column value equals the specified value.$ awk '($10 == value)'try on your machineexplain this command
-
awk:tldr:e6726 awk: Print the second column of the lines containing "foo" in a space-separated file.$ awk '/${foo}/ {print $2}' ${filename}try on your machineexplain this command