Questions tagged [awk]

Ask Question

awk is a special-purpose, interpreted programming language for extracting and reporting data.

493 questions
87 votes 5 answers 379k views

How to separate fields with space or tab in awk

While playing with awk I came to execute: ls -la >> a.txt ; awk {'print $5 $1'} a.txt ; This is giving output like: 53277-rw------- 52347-rw------- How can I get a space between these two ... user avatar rɑːdʒɑ
  • 96.1k
42 votes 2 answers 114k views

What does this command mean: awk -F: '{print $4}'?

Please explain what does following command mean: awk -F: '{print $4}' user avatar PHP Learner
  • 2,528
22 votes 5 answers 18k views

How can I merge files on a line by line basis?

cat file1 foo ice two cat file2 bar cream hundred Desired output: foobar icecream twohundred file1 and file2 will always have the same amount of lines in my scenario, in case that makes things ... user avatar TuxForLife
  • 1,285
17 votes 5 answers 60k views

How can I process multi-line records with awk in a bash script?

example.txt is below Restaurant: McDonalds City: Miami State: Florida Address: 123 Biscayne Blvd Phone: 911 Restaurant: 5 guys City: Atlanta State: Georgia Address: 123 Peachtree Rd Phone: 911 ... user avatar Selena Gomez
  • 275
15 votes 5 answers 7k views

Difference of two big files

I have "test1.csv" and it contains 200,400,600,800 100,300,500,700 50,25,125,310 and test2.csv and it contains 100,4,2,1,7 200,400,600,800 21,22,23,24,25 50,25,125,310 50,25,700,5 now diff test2.... user avatar Lynob
  • 6,451
13 votes 3 answers 34k views

How do I replace multiple lines with single word in file(inplace replace)?

Content of my filename file is as following(for example): My block of line starts from here START First line second line third line END and end to here for example. I want to replace block of lines ... user avatar αғsнιη
  • 33.6k
13 votes 4 answers 39k views

How to delete lines starting with certain strings

Is there a way to delete lines starting with certain strings. I have this youtube-dl code youtube-dl --extract-audio --audio-quality 0 --newline --audio-format mp3 user avatar potholiday
  • 575
12 votes 6 answers 9k views

grep to return Nth and Mth lines before and after the match

I know that with grep I can use the fields -A and -B to pull previous and next lines from a match. However they pull in all lines between the match based on however many lines are specified. grep -... user avatar chollida
  • 225
12 votes 3 answers 104k views

Extract word from string using grep/sed/awk

I have a string 00:28:04 /usr/lib/jvm/jre/bin/java -DJDBC_CONNECTION_STRING= -Dspring.profiles.active=qa -XX:MaxPermSize=256 and want to extract the word qa that follows -Dspring.profiles.active. ... user avatar Gman
  • 471
10 votes 6 answers 5k views

How to remove the first colon ':' from a timestamp?

I am new to programming!! Can anyone help to remove the : at the first position in a timestamp: :29.06.2019 23:03:17 Presently I am trying to do it using awk/cut commands as shown below: TDS="$(... user avatar Manoj Kumar
  • 333
10 votes 3 answers 9k views

awk - How to print the number of characters for the first n lines in a file?

I have a command: $ awk '{ print length($0); }' /etc/passwd It prints number of characters of every line in a passwd file: 52 52 61 48 81 58 etc. How can I print the number of characters for only ... user avatar bambosze_babuni
  • 167
10 votes 1 answer 28k views

Do I need to install awk or is it inbuilt in Ubuntu?

I'm new to Linux OS and studying Mobile Computing. I have to analyze files using awk. I'm using Ubuntu 14.04. Do I need to install awk or is it inbuilt in Ubuntu? user avatar NIMISHAN
  • 1,461
9 votes 7 answers 29k views

How to use sort on an awk print command?

I have a couple of commands in an awk script I'm writing: print "Here are some players and their numbers, sorted by last name" if(sum[x] > 500) {print x, $2} Which outputs: Here are some players ... user avatar Anonymous
  • 405
9 votes 5 answers 856 views

Only get the H+W geometry of my screen without the later +x+y

I am reading this article. There is a statement there that goes: ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -r 25 -i :0.0 -sameq -f mpeg -ar ... user avatar Guest123ABC
  • 171
9 votes 2 answers 2k views

Using AWK to get second column

I can not seem to get the awk command to get the second column of data. Bash Code: filter_data=$(awk "{if(/$filter:/) print $2}" < scanresults_temp.txt) printf "$filter_data \n" The $filter ... user avatar Vlad
  • 93

15 30 50 per page1234533

You Might Also Like