Sed with sort doesnt work


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sed with sort doesnt work
# 1  
Old 05-20-2009
Sed with sort doesnt work

Sed with sort doesnt work

Quote:
file1
abc,def
abc,klm
,,
The below code doesnt work:
Code:
sed -e '/^$/d' -e 's/,/|/g' | sort -t"|" -k1,1 -u file1

when i seperate them it work but i have to create intermediate file which i dont want to:
Code:
sed -e '/^$/d' -e 's/,/|/g'  file1 > file2
sort -t"|" -k1,1 -u file2

Quote:
Output:
||
abc|def
Help is appreciated
# 2  
Old 05-20-2009
Question

I think your initial sed command is still waiting for input

Code:
sed -e '/^$/d' -e 's/,/|/g' | sort -t"|" -k1,1 -u file1

maybe?
Code:
sed -e '/^$/d' -e 's/,/|/g' file1 | sort -t"|" -k1,1 -u >file2

# 3  
Old 05-20-2009
Quote:
Originally Posted by zenith
Sed with sort doesnt work

The below code doesnt work:
Code:
sed -e '/^$/d' -e 's/,/|/g' | sort -t"|" -k1,1 -u file1


You gave the file to sort instead of to sed.

Code:
sed -e '/^$/d' -e 's/,/|/g' file1 | sort -t"|" -k1,1 -u

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

why doesnt it work?

I am trying to print out two fields in a file using awk. So, I have got awk -F '\t' 'NF = 2 {print $1 $2 "]"}' two.txt in a script called what.awk When i run this version like this - ./what.awk then it runs however I want to run the program like this awk -f what.awk two.txt. When I... (8 Replies)
Discussion started by: The undertaker
8 Replies

2. AIX

Vi doesnt work

Hi Guys, I have a strange problem.( AIX 6.1) "vi" is not working at all..Whenever i #vi <anythin> ,, it returns the prompt back. Any clues folks?? (14 Replies)
Discussion started by: muzahed
14 Replies

3. Shell Programming and Scripting

compiler doesnt work

this is my file I have written. // My first C++ program #include <iostream> int main() { std::cout << "Hi there!" << std::endl"; std::cout << "This is my first C++ program" << std::endl"; return(0); } This is the error I get, why? $ g++ first.cpp ksh: g++: not found (1 Reply)
Discussion started by: gustave
1 Replies

4. Shell Programming and Scripting

loop doesnt work

It just does the break...even though the files are not the same... # Compare extracts #========================================== count=0 while (( count < 5 )) do (( count+=1 )) echo "Try $count" file1=$(ls -l /tmp/psjava.xml|... (5 Replies)
Discussion started by: sigh2010
5 Replies

5. AIX

tar -xvf doesnt work

Hello Im trying to extract this file tar -xvf opt-samba-base.tar.tar tar: 0511-169 A directory checksum error on media; 0 not equal to 75420. but I get that message I tried algo with gunzip and uncompress but nothing happens gunzip -d opt-samba-base.tar.tar gunzip:... (2 Replies)
Discussion started by: lo-lp-kl
2 Replies

6. Red Hat

ldapsearch doesnt work.

Hii All, I am using openldap v2.3 on redhat El-4. When i run ldapsearch it returns all the entries. The command runs successfully. But when I run the ldapsearch with following filter option it doesnt work and immediately returns to the shell. ldapsearch uidNumber>=2000 I've started slapd... (0 Replies)
Discussion started by: shamik
0 Replies

7. UNIX for Dummies Questions & Answers

cp doesnt work - Help

When trying to copy a file in Solaris 8 it doesnt copy file or give a error. This worked 100% until the 29th. I've checked the rights and everything seems fine: drwxrwxrwx 2 bmuser bmgroup 11776 Jan 3 10:32 spool This is the file I want to copy: -rwxrwxrwx 1 bmuser bmgroup ... (26 Replies)
Discussion started by: rudi.okelly
26 Replies

8. HP-UX

ls command doesnt work

Good Day I mistakely renamed the dld.sl file in the /usr/lib directory. When i try to ls/ftp into the box i get this error :eek: crt0: ERROR couldn't open /usr/lib/dld.sl errno:000000002 I have tried to rename it back from the renamed file to the original file name, but it gives me the... (2 Replies)
Discussion started by: shawnbishop
2 Replies

9. UNIX for Dummies Questions & Answers

cd.. doesnt work

hi when i want to go to previous directory by typing cd.. i get the following message $ cd.. ksh: cd..: not found Please help rintingtong (2 Replies)
Discussion started by: rintingtong
2 Replies

10. Shell Programming and Scripting

why doesnt my script work!!!

Is there a utility or command I can use to tell the number of decimal places a number has. For instance, if the number is 432, it will give hundred as the number of decimal places. (7 Replies)
Discussion started by: Heedunk
7 Replies
Login or Register to Ask a Question