Visit Our UNIX and Linux User Community


How to use cat and sort commands combinations?


 
Thread Tools Search this Thread
Operating Systems AIX How to use cat and sort commands combinations?
# 1  
Old 12-18-2007
How to use cat and sort commands combinations?

Hi,
I need to get five names as input and sort it. It has to be done in the command level only. It should not read from any files.

I tried with many combinations. I didnt get it.

I can able to get the input using

cat > sample
jik
njvi
abifj

...like this and i dont know how to sort it here.

Many Thanks.
# 2  
Old 12-18-2007
once file <sample> is ready

use the command sort

Is that what you are looking for ?
# 3  
Old 12-18-2007
Quote:
Originally Posted by Yamini Thoppen
Hi,
I need to get five names as input and sort it. It has to be done in the command level only. It should not read from any files.

I tried with many combinations. I didnt get it.

I can able to get the input using

cat > sample
jik
njvi
abifj

...like this and i dont know how to sort it here.

Many Thanks.

How do you want to sort them...alphabetically or its inverse?

Code:
cat <<EOF | sort -k1,1
jik
njvi
abifj
yada_yada
blah_blah
EOF

# 4  
Old 12-19-2007
Thanks.Exactly i want this only.

Quote:
Originally Posted by shamrock
How do you want to sort them...alphabetically or its inverse?

Code:
cat <<EOF | sort -k1,1
jik
njvi
abifj
yada_yada
blah_blah
EOF

Hi Shamrock,

Exactly i want this only..Many Thanks to you
# 5  
Old 12-19-2007
Thanks

Quote:
Originally Posted by matrixmadhan
once file <sample> is ready

use the command sort

Is that what you are looking for ?
Hi Madhan,

I have gonethrough your reply. But i want exactly the Shamrock codings which he is given.

cat <<EOF | sort -k1,1
jik
njvi
abifj
yada_yada
blah_blah
EOF

Previous Thread | Next Thread
Test Your Knowledge in Computers #855
Difficulty: Medium
JSX (JavaScript XML) is an extension to the JavaScript language syntax.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending output of program into subsequent commands (i.e. awk/sort)

Hi, I have identified how to use command chaining as per below on a file, to capture the header of a file, as well as the line containing the C: drive. $ cat test.txt Filesystem Size Used Avail Use% Mounted on rootfs 237G 153G 84G 65% / none 237G 153G 84G ... (6 Replies)
Discussion started by: sand1234
6 Replies

2. Shell Programming and Scripting

OSX, bash, cat with <<MARKER executing commands

I have a script that writes another script with cat >/usr/local/bin/myscript.sh <<EOF #!/bin/sh VAR=`run a command here` EOF Problem is, after this is run, I get: $ cat /usr/local/bin/myscript.sh #!/bin/sh VAR=result of command How do I stop that from happening with Macs... (2 Replies)
Discussion started by: jnojr
2 Replies

3. Shell Programming and Scripting

replace cat huge_multiplefiles |sort |uniq -c

Does any one know any command runs faster than this to give duplicate numbers cat file1 file2 ....file 100 | sort |uniq -c thanx (3 Replies)
Discussion started by: quincyjones
3 Replies

4. UNIX for Advanced & Expert Users

$cat file|sort|uniq

I have a file with list of redundant server names and want only unique ones of those. I have used following command but still redudant ones are listing $cat file|sort|uniq where could be the problem. Thanks, Srinivas (3 Replies)
Discussion started by: srinivas Juluri
3 Replies

5. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

6. UNIX for Dummies Questions & Answers

Using the Sort, Cut, and Awk commands

Hello, I am trying, utilizing the few commands I know, to extract all records within my file that were generated in November of 2007. Each record within the file has a "date" field giving the month, day, and year (9-8-88). How do I extract those records to their own file? Once I extract... (4 Replies)
Discussion started by: babbabooey
4 Replies

7. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

8. UNIX for Advanced & Expert Users

Combinations

Hello All, i have two files, one of the format A 123 B 124 C 234 D 345 And the other A 678 B 789 C 689 D 567 I would like to combine them into one file with three columns: A 123 678 B 124 789 C 234 689 (4 Replies)
Discussion started by: Khoomfire
4 Replies

9. UNIX for Dummies Questions & Answers

Need Help with Awd/sort commands

Can anyone give me a hand with some questions by e-mailing me directly, so I can relay the questions inorder. I really would appreciate anyone that can help. Thank You in advance, I am online and will reply instantly. Charley <email removed> (5 Replies)
Discussion started by: flarebel
5 Replies

Featured Tech Videos