Hi all,
I am using this command "sort -d -u -k1 IMSTEST.74E -o tmp.txt" to the records in the flat.
Can any tell me how to sort the file except first line in the file
For ex:
i/p
First line: DXYZ
Second line : jumy
third : cmhk
fourth : andy
Output should be:
DXYZ
andy
cmhk
jumy
Thanks In Advance
Sudhir
pludi
2
head -n 1 IMSTEST.74E > tmp.txt
tail -n +2 IMSTEST.74E > main.txt
sort -d -u -k1 main.txt >> tmp.txt
rm main.txt
You can use only 'sort tmp.txt'. It should work fine.
#! /usr/bin/perl
open FH,"<a.txt";
while(<FH>){
chomp;
my @tmp=split(":",$_);
push @arr,$tmp[1]."\n";
}
print $arr[0],sort @arr[1..$#arr];
head -1 file >tmp.txt&&sed '1d' file|sort -d -u -k1 >>tmp.txt
Or simply with awk:
awk '{print $NF|"sort"}' file
Regards