using awk to print some columns of a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using awk to print some columns of a file
# 1  
Old 12-16-2010
using awk to print some columns of a file

Hi,
i have a file with content
Code:
00:01:20.613 'integer32' 459254
00:01:34.158 459556
00:01:36.626 'integer32' 459255

and i want to print only output as below
Code:
00:01:20.613 459254
00:01:34.158 459556
00:01:36.626 459255

i dont want the word 'integer32' which is the second column.

i tried
Code:
awk -F" " '$2=='integer32' && $3>0 { print $1,$3 }'  zddd.txt >> zresult.txt

but it does not work.
Please assist

Last edited by Scott; 12-16-2010 at 11:56 AM.. Reason: Please use code tags
# 2  
Old 12-16-2010
For the provided input, try this:
Code:
awk '{print $1,$NF}' file

# 3  
Old 12-16-2010
thank you, both worked
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use "awk" to print columns from different files in separate columns?

Hi, I'm trying to copy and paste the sixth column from a bunch of files into a single file having each column pasted in separate columns (and not one after each other in just one column.) I tried this code but works only partially because it copied and pasted 50 rows of each column... (6 Replies)
Discussion started by: Frastra
6 Replies

2. Shell Programming and Scripting

awk print columns and variable

Hi, Can anyone help with the below please? I have written some code which takes an input file, and and prints the contents out to a new file - it then loops round and prints the same columns, but increments the ID column by 1 each time. Input file; NAME,1,15-Dec-15, NAME,1,21-Dec-15,... (9 Replies)
Discussion started by: Ads89
9 Replies

3. Shell Programming and Scripting

awk print columns which are not null

I am working on a file with several columns as below MO_NAME,FAULT_TYPE,CLASS,CODE1,CODE2,CODE3 RXOCF-101,BTS INTERNAL,FAULT CODES CLASS 2A,53,58 RXOCF-101,BTS INTERNAL,FAULT CODES CLASS 2B,24 RXOCF-101,BTS INTERNAL,FAULT CODES CLASS 2A,33 RXOCF-101,BTS INTERNAL,FAULT CODES CLASS 2D,57 ... (12 Replies)
Discussion started by: Rizwan Rasul
12 Replies

4. Shell Programming and Scripting

Awk: is it possible to print into multiple columns?

Hi guys, I have hundreds file like this, here I only show two of them: file 1 feco4_s_BB95.log ZE_1=-1717.5206260 feco4_t_BB95.log ZE_1=-1717.5169250 feco5_s_BB95.log ZE_1=-1830.9322060... (11 Replies)
Discussion started by: liuzhencc
11 Replies

5. Shell Programming and Scripting

[Solved] awk compare two different columns of two files and print all from both file

Hi, I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this File1 1 rs1 abc 3 rs4 xyz 1 rs3 stu File2 1 kkk rs1 AA 10 1 aaa rs2 DD 20 1 ccc ... (2 Replies)
Discussion started by: justinjj
2 Replies

6. Shell Programming and Scripting

Awk print all columns in delimited file

text file example 1,222222222222,333,444444444444444 111111111,22,33333333,444 desired output 1 222222222222 333 444444444444444 111111111 22 33333333 444I have a delimeted file which I want to print in a table like format. The... (10 Replies)
Discussion started by: Calypso
10 Replies

7. Shell Programming and Scripting

awk compare specific columns from 2 files, print new file

Hello. I have two files. FILE1 was extracted from FILE2 and modified thanks to help from this post. Now I need to replace the extracted, modified lines into the original file (FILE2) to produce the FILE3. FILE1 1466 55.27433 14.72050 -2.52E+03 3.00E-01 1.05E+04 2.57E+04 1467 55.27433... (1 Reply)
Discussion started by: jm4smtddd
1 Replies

8. Shell Programming and Scripting

grep/awk to only print lines with two columns in a file

Hey, Need some help for command to print only lines with two columns in a file abc 111 cde 222 fgh ijk 2 klm 12 23 nop want the ouput to be abc 111 cde 222 ijk 2 Thanks a lot in advance!!! (3 Replies)
Discussion started by: leo.maveriick
3 Replies

9. Shell Programming and Scripting

Removing columns from awk '{ print $0 }'

I have a one-line command, lsusb | awk '{ $1=""; $2=""; $3=""; $4=""; $5=""; $6=""; print $0 }' It works, and gives the results I expect, I was just wondering if I am missing some easier way to nullify the first 6 column variables? Something like, lsusb | awk '{ $(1-6)=""; print $0 }' But... (10 Replies)
Discussion started by: AlphaLexman
10 Replies

10. Shell Programming and Scripting

cannot print the columns i want with awk.

hi friends! i have a script where a execute a veritas command, available_media wich retrieves me a list of tapes .lst then i execute cat /tmp/listtapes.lst | grep -v VL |sed '/^$/d'|awk -F, '{print $1, $3, $4, $9} ' > /tmp/media1.lst but it prints all the columns instead of the four... (3 Replies)
Discussion started by: pabloli150
3 Replies
Login or Register to Ask a Question