How do you print column 1 from comm output to a file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do you print column 1 from comm output to a file?
# 1  
Old 02-12-2010
How do you print column 1 from comm output to a file?

Hi guys,

I have a script, which after running for 20 minutes,
produces a bunch of IPs. Due to a DHCP scope, some of these IPs
are not useable, so I would like to eliminate them from the final list.
I have used comm to do this, but am unable to extract the first column,
and redirect it to a file. I've spent 30 minutes trying to do this Smilie
Could you guys help me out?
I need column 1 below in the file, and I don't want column 2 in there.
I've tried awk, but it produces nothing but 40+ blank lines if I print $2 3 4, etc.

Real IPs removed.

Thanks

Code:
knock@box01:~/userName$ comm -3 temp1 temp2 | awk '{ print $0}'

1.2.3.1
1.2.3.2
        1.2.3.1
        1.2.3.2
        1.2.3.3

I need 1.2.3.1 and 1.2.3.2 and 1.2.3.3 in a file,
which will be the addresses we know we can safely use.
# 2  
Old 02-12-2010
Output of comm is delimited by tab. Awk uses space as default delimiter
Code:
awk -F"\t" ' { print $2 } '

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert rows to column and print output in required format

Hi All, i am trying to print the solaris 11 packages in below required format, But i am unable to do that. Current ouput : root@abc# pkginfo -l | egrep '(BASEDIR|NAME|VERSION)' | awk '{print}' NAME: QLogic 570x/571x Gigabit Ethernet Driver VERSION: 11.11,REV=2009.11.11 ... (7 Replies)
Discussion started by: balu1234
7 Replies

2. UNIX for Beginners Questions & Answers

Need to print nth till last column of ls output using sed

I wish to print first, third and sixth till the last column from the output of ls command ls -ltr /app/deploy.yml -rw-rw-r-- 1 user1 dba 27342 Aug 28 10:17 /app/deploy.yml Desired Output: Below command gives me the desired output. ls -ltr /app/deploy.yml | awk '{$2=$4=$5=""; print... (6 Replies)
Discussion started by: mohtashims
6 Replies

3. Shell Programming and Scripting

Highlight 'comm' command output

Given the output below (simplified) extracted from the comparison of two curl -I commands saved in two different files, I am looking for the best approach to highlight the following scenarios in a script: this header exists only in file1.txt but this one does not this one exists in both cases... (1 Reply)
Discussion started by: muppets
1 Replies

4. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

5. UNIX for Dummies Questions & Answers

Print each output of loop in new column using awk or shell

I have this output from a loop a11 1,2 3,4 5,6 7,8 12,8 5,4 3,6 a12 10,11 12,13 15,18 20,22 a13 ... (3 Replies)
Discussion started by: maryre89
3 Replies

6. Shell Programming and Scripting

Print a column with the name of the output file

I have n files and I am using cat to combine them in to one. Before that simply add the name of the output file to 4th column and then print the output. Is it possible ? input1 chr start end name 0 + key input2 chr start end name 0 + key inputn... (1 Reply)
Discussion started by: quincyjones
1 Replies

7. Shell Programming and Scripting

Comm compare, but column specific

I'm looking to compare two delimited files: file1 one|xxx two|xxx three|xxx file2 four|xxx five|xxx six|xxx one|yyy Where the result is the the file2 row whose first field does NOT appear in file1. I.e., the correct result would be: result four|xxx (3 Replies)
Discussion started by: tiggyboo
3 Replies

8. Shell Programming and Scripting

comparing column of two different files and print the column from in order of 2nd file

Hi friends, My file is like: Second file is : I need to print the rows present in file one, but in order present in second file....I used while read gh;do awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile done < secondfile but the output I am... (14 Replies)
Discussion started by: CAch
14 Replies

9. Shell Programming and Scripting

comm -12 based on 1 column

I'd like to eliminate the rows in two files that do not share a common value in the first column. Here's my tortured logic that is way too inefficient to consider, but might show what i'm trying to do (assume the files have been sorted): cut -f1 -d '|' file1 > file1.dat cut -f1 -d '|' file2 >... (4 Replies)
Discussion started by: tiggyboo
4 Replies

10. Shell Programming and Scripting

Can we use 'tr' command to print 5th column of output of 'ls -l'

Hi All, I know awk command can do it, but can we use tr command to print 5th column of out put 'ls -l' command???? Regards, Nidhi... (4 Replies)
Discussion started by: Nidhi2177
4 Replies
Login or Register to Ask a Question