Apr 5, 2010 #1 jdhahbi Technical User Oct 7, 2009 24 US Hi I want to print column2 if column1 is b with: Code: awk '$1==b {print $2}' infile > outfile infile a 1 b 2 c 3 b 4 e 5 b 6 please help joseph the outfile is empty. it should look like this: 2 4 6
Hi I want to print column2 if column1 is b with: Code: awk '$1==b {print $2}' infile > outfile infile a 1 b 2 c 3 b 4 e 5 b 6 please help joseph the outfile is empty. it should look like this: 2 4 6
Apr 5, 2010 #2 p5wizard IS-IT--Management Apr 18, 2005 3,165 BE Try to compare with the string literal "b" instead of just the name b. Right now you're comaparing with an uninitialized (so zero value) variable called b, so only if column 1 is zero your print $2 instruction would run. HTH, p5wizard Upvote 0 Downvote
Try to compare with the string literal "b" instead of just the name b. Right now you're comaparing with an uninitialized (so zero value) variable called b, so only if column 1 is zero your print $2 instruction would run. HTH, p5wizard
Apr 5, 2010 Thread starter #3 jdhahbi Technical User Oct 7, 2009 24 US thank you very much Upvote 0 Downvote