Increasing order


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Increasing order
# 1  
Old 07-21-2013
Increasing order

Hi ,

I have around 1000000 odd lines in a file in random order.

The file looks like this:

Code:
>string102
>string10437183
>string514
>string10435771
>string10437259
>string1049931
>string1342

I want to arrange it in increasing order:
Code:
>string102
>string514
>string1342
>string1049931
>string10435771
>string10437183
>string10437259

How can I arrange it in increasing order using grep??

Moderator's Comments:
Mod Comment edit by bakunin: When we ask to use CODE-tags we really mean it. They aren't optional. These were added as a gift by me, but the next time you should bring your own ones to the party. Thanks.

Last edited by bakunin; 07-21-2013 at 08:31 PM..
# 2  
Old 07-21-2013
Quote:
Originally Posted by qwerty193
How can I arrange it in increasing order using grep??
Not at all, because "grep" is a filtering tool: you can filter out lines which contain certain patterns with it, but not reorder lines.

I suggest you read the man page of "sort", which will do what you want. The construction of the appropiate key is left to the interested reader, just so much: let the sort key begin at the n+1-th character of the line where N is the number of characters in ">string", so that the sort key only consists of the random number. Then sort simply numerically.

I hope this helps.

bakunin
# 3  
Old 07-22-2013
will the string be a fixed size or variable
# 4  
Old 07-23-2013
Code:
sort -nk1.8,1.20 filename

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

increasing interlace size

Hi All, I have got a RAID 5 SVM in my Solaris Box. Recently we had performance issues with it. So SUN has told us to increase the interlace size to 128k. how can we do it so that we have to recreate the RAID 5. ALso guide what are all the pre cautions that we need to take before doing... (1 Reply)
Discussion started by: jegaraman
1 Replies

2. Solaris

Increasing inodes

Hi , Can someone help me to increase "inode" in solaris 9? Thanks in advance, Gowtham (8 Replies)
Discussion started by: gowthamakanthan
8 Replies

3. UNIX for Dummies Questions & Answers

Increasing swap space

I searched the archives first, but found that there are alot of mixed answers on whether swap space can or can not be increased. Some postings said swap space can be increased using the swap or growfs commands while other postings said you can not increase the permanent size of the swap space. ... (1 Reply)
Discussion started by: Kevin1166
1 Replies

4. HP-UX

Increasing swap size

We increased our server's RAM 8 -> 32 GB RAM. swap memory is currently 10 GB. With which command I can increase this memory? (1 Reply)
Discussion started by: akyuceisik
1 Replies

5. UNIX for Dummies Questions & Answers

Increasing Disk Quota

I keep getting an error on my site that says: The server is a 250gb dedicated server so I would have thought I had more than enough space. What does this actually mean and can I increase the disk quota? Thanks (0 Replies)
Discussion started by: thehaapyappy
0 Replies

6. Solaris

increasing /var

i need to increase the size of my /var filesystem but i have no idea how to do it. Filesystem kbytes used avail capacity Mounted on /dev/dsk/c0t3d0s0 144799 74952 55377 58% / /dev/dsk/c0t3d0s6 342183 201079 106894 66% /usr /proc ... (0 Replies)
Discussion started by: roguekitton
0 Replies

7. HP-UX

Help on increasing fs size

Hi Experts, I am not sure whether my question should be in this thread or some other one. I am using HP Tru64 system. Currently one of my filesystem /others is almost full. I need to know the exact commands to increase this filesystem. Please show me how to check for free partitions and add... (5 Replies)
Discussion started by: kingsto88
5 Replies

8. Debian

Increasing resolution in Debian?

I only see 800x600 in my 'resolution' list but my screen is capable of 1024x768. How can I increase it? I remember that I got the option when installing the system but I recently installed and wasn't prompted. /Richard (3 Replies)
Discussion started by: riwa
3 Replies

9. UNIX for Advanced & Expert Users

increasing file system

Hi, on /dev1 I have 50Gb, on /dev2 I have 5Gb. How can I give the 50Gb to /dev2 and give back 5Gb to /dev1. Many thanks. PS : OS is AIX (1 Reply)
Discussion started by: big123456
1 Replies

10. Programming

memory increasing

On Alpha True64 UNIX platform, we use "ps aux" command to display the process information, it also displays the %MEM,VSZ, RRS field. The question is that which field really indicates the program's memeory is increasing, thanks (0 Replies)
Discussion started by: Frank2004
0 Replies
Login or Register to Ask a Question