uniq not working, so any alternate?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting uniq not working, so any alternate?
# 1  
Old 05-12-2011
uniq not working, so any alternate?

Hi,

I have these two files .

Code:
file1
/home/prog/bug/perl
/home/prog/bug/ant
/home/prog/bug/make
/home/prog/bug/gen
/home/prog/bug/tiff


file2
/home/prog/bug/make
/home/prog/bug/gen

i want a output file which should contain

Code:
file1-file2
/home/prog/bug/perl
/home/prog/bug/ant
/home/prog/bug/tiff

My code

Code:
cat file1 file2 > temp
sort temp > /dev/null
uniq -u temp > file3
rm -f temp

but i didnt get the required output. I am using tcsh.

So i need some idea to write this script.
# 2  
Old 05-12-2011
Try this...

Code:
sort temp | uniq -u

# 3  
Old 05-12-2011
Works fine in bash like this:

Code:
 sort file1 file2 | uniq -u

This User Gave Thanks to r4v3n For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Alternate for sed -i in AIX

Experts, At the moment I am working in AIX box where sed -i is not available. My requirement is as below Two files file1 and file2. file1 contains the IP address, its count. file2 contains the Hostname and its corresponding IP address. I would like get the IP address replaced with the apt... (7 Replies)
Discussion started by: sathyaonnuix
7 Replies

2. HP-UX

Alternate for wget

Hi, Whats the alternate for wget in HP-UX ? (4 Replies)
Discussion started by: mohtashims
4 Replies

3. Shell Programming and Scripting

Cron for an alternate sunday

Hi again, I need to delete stats on every 2nd Sunday and I've try the following codes but unfortunately it didn't work. I'll really appreciate as always for your help. I'm on FreeBSD 8.2-STABLE. altsun.sh script: #!/bin/sh day = $(`date '+%e'`) if then rm... (9 Replies)
Discussion started by: user`
9 Replies

4. Shell Programming and Scripting

sed working as uniq 1st word only

Hello, everyone. I am having trouble figuring out sed command which emulates uniq. The task I want to do is that 2 consecutive lines in file should be considered the same using the first word only. Example: cat tmp.txt ddd eee aaa bbb ccc ddd eee fff asd fdd asd fdd bbb aaa bbb asd fgh... (4 Replies)
Discussion started by: motorcek
4 Replies

5. Shell Programming and Scripting

Wants alternate to the Sleep option??

I am new to Shell Scripting and I need help to write the following script in a different format... This is the current script: #!/usr/bin/ksh environment=rms export environment . $AW_HOME/RETEK/exec/RETEK_ENVAR ls -ltr $MMPOS/RTLOG* | tr -s " " | cut -d " " -f9... (20 Replies)
Discussion started by: satyajit007
20 Replies

6. UNIX for Dummies Questions & Answers

Difference between plain "uniq" and "uniq -u"

Dear all, It's not entirely clear to me from manpage the difference between them. Why we still need "-u" flag? - monkfan (3 Replies)
Discussion started by: monkfan
3 Replies

7. Shell Programming and Scripting

alternate lines

Hi, I'm new to Unix. I want to read the all the lines from a text file and write the alternate lines into another file. Please give me a shell script solution. file1 ----- one two three four five six seven newfile(it should contain the alternate lines from the file1) ------- one... (6 Replies)
Discussion started by: pstanand
6 Replies

8. Shell Programming and Scripting

Alternate way for echo.

Hi, Is there any other command echo does. if I am doing this operation for each line in my file. So its taking very long time to process more than 1000 records. Is there any alternative way to write the above if statement (5 Replies)
Discussion started by: senthil_is
5 Replies

9. Shell Programming and Scripting

alternate rows of a file

hi all is there any process in which i can get alternate rows of a file.i want to do further processing on those alternate rows.i want to select row1,row3,row5.... like this from a file. (3 Replies)
Discussion started by: dr46014
3 Replies
Login or Register to Ask a Question