The command:
sorts file with a sort key that starts with the 1st character on each line and continues to the end of the line. What was requested was:
which sorts with a key being the 1st six characters of the 1st field on each line.
But, since we aren't doing a numeric sort and we aren't performing a reverse order sort, both of the above, and the simpler:
will all do exactly the same thing.
This User Gave Thanks to Don Cragun For This Post:
Instead of searching Google for answers about how a utility works, try reading the man page for that utility on your system. In this case try the command:
to see the man page for the sort utility on your system. The behavior of lots of utilities varies from system to system. What you find on Google MIGHT or MIGHT NOT explain how the utility you're searching for will work on your system; the man page on your system WILL explain how the utility will work on your system.
If the man page on your system doesn't answer your question, or you don't understand what some of the words on the man page on you system mean; create a sample data file and try sorting with sort file (which your man page will explain performs an alphanumeric sort) and sort -n file (which your man page will explain performs a numeric sort). For example, if file contains:
then an alphanumeric sort (sort file) produces:
while a numeric sort (sort -n file) produces:
If you can't figure out why your examples aren't working the way you think they should, show us the sample input you used, the output you got, the code you used to transform that sample input to the output you got, show us the output you wanted to get (or expected to get), and explain what you didn't understand on the man page or what you were trying to do that didn't work.
We will be happy to help you figure out how to use the tools available on your system; we will quickly get tired of being asked to do someone else's work for them if they don't seem to be interested in learning how to do it on their own.
Hello,
I have a file such as this:
chr1
chr2
chr1
chr2
chr3
chr10
chr4
chr5
chrz
chr1AI want to sort it, I use this command:
sort -k1 -th -n testfilebut I get this output, how can I fix this?
chr1
chr1
chr10
chr1A
chr2
chr2 (3 Replies)
Hi Unix Experts,
I am trying to send mail from Unix to my email id configured on outlook. I need to make sure it works as a follow-up. I am using the below code my AIX unix box.
/usr/sbin/sendmail -t << EOM
X-Priority: 1
X-Message-Flag: Follow up
Reply-By: 15/06/2011 10:00... (1 Reply)
Hi,
The OS is SuSE Enterprise 11 and the system is HP WS460c G6 Blade with hardware disk array RAID 1 mirror. One disk was just replaced and the disk mirroring process is on its way. My question is how to follow up / monitor the disk mirroring process? I know hpacucli can do the job, but there... (0 Replies)
Hello Guys,
I'm currently creating a script for a couple of things and I'm semi stuck on where to go next.
This is the script i've written but its not working in the exact way i want it to work.
#!/bin/bash
while :
do
clear
echo " M A I N - M E N U"
echo "1. Make a New... (1 Reply)
Hi,
I often need to find the child processes of a parent process. There may be a string of 4-5. That is, PPID 884 spawns 890, which spawns 894, which spawns 1017. I'd like to be able to see all of them without having to type in a number of ps -ef commands.
Process groups and session ID's are... (2 Replies)
This is a follow-up re: this thread
As I mentioned, this script works very nicely, thanks again.
However, the ASCII data of the 'attached file' also shows below the body of the email message. Do you know of a way to 'disable' the attached text from showing? Although the file is attached,... (3 Replies)