unix sort according to a header line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix sort according to a header line
# 1  
Old 02-08-2010
unix sort according to a header line

Hi,

I have a file with a header line, followed by some contents. How can I sort the file according to header lines?

eg.
/* abcd_005*/
a
bc
/* abcd_001*/
d
e
/* abcd_002*/
x
y



desired output:

/*abcd_001*/
d
e
/*abcd_002*/
x
y
/*abcd_005*/
a
bc
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort without Header and Trailer

Hi , My UNIX system is SUN Solaris. I am trying to do a simple thing as described below. I have a PIPE delimited file that has header and trailer. So the file is something like below: Test1.txt looks like something below: field_data1|field_data2|and some more data --Header ... (5 Replies)
Discussion started by: Saanvi1
5 Replies

2. Shell Programming and Scripting

Sort and Split file with header and custom name

Hi, I am using SUN SOLARIS (SunOS sun4v sparc SUNW, T5240). I have a huge data file with header and trailer. This file gets used into an ETL process. ETL skips the header record (which is the first record of the file) and loads the rest of the record. The file can be delimited (comma,... (5 Replies)
Discussion started by: Saanvi1
5 Replies

3. UNIX for Dummies Questions & Answers

Sort a las file keep the header as it is

I have several las files with a header and each file start Version and text and before the data starts end up with ~Ascii, then the numbers starts: ------------------------------------------------------------------------- ~Version .....text.... ~Ascii 2 abc 230 1 name 1 abc 400 1... (17 Replies)
Discussion started by: tk2000
17 Replies

4. UNIX for Dummies Questions & Answers

Sort a las file keep the header as it is

I have several las files with a header and each file start Version and text and before the data starts end up with ~Ascii, then the numbers starts: ------------------------------------------------------------------------- Code: ~Version .....text.... ~Ascii 2 abc 230 1 name 1 abc ... (1 Reply)
Discussion started by: tk2000
1 Replies

5. UNIX for Dummies Questions & Answers

Sort a tab file with header.

How to sort a tab delimited file first on col1 and then on col2. Also I need to keep the header intact. file.txt val1 val2 val3 val4 a b c d m n o p e f g h i j k l ... (3 Replies)
Discussion started by: mary271
3 Replies

6. Shell Programming and Scripting

Simple sort with header

Hi, Please help with this problem. Somehow does not work for me. test.txt CHR SNP BP A1 C_A C_U A2 CHISQ P OR 19 rs10401969 19268718 C 222 890 T 0.03462 0.8524 0.9857 1 rs10873889 ... (4 Replies)
Discussion started by: genehunter
4 Replies

7. Shell Programming and Scripting

bash ps; remove the header, sort and reinsert

Hi, I'm ssh'ing into a server using ruby and sending a one-liner to retrieve the output of the 'ps aux' command. So far, this is what I have: ps aux | sort -r -n -k3 | sed -e '1s/^/this is first\n/' | head -n10 With this I can insert a line at position 1, but I would rather extract the... (3 Replies)
Discussion started by: gekeha
3 Replies

8. UNIX for Dummies Questions & Answers

Sort and uniq lines of a file while keeping a header line

So, I have a file that has some duplicate lines. The file has a header line that I would like to keep at the top. I could do this by extracting the header from the file, 'sort -u' the remaining lines, and recombine them. But they are quite big, so if there is a way to do it with a single... (1 Reply)
Discussion started by: Digby
1 Replies

9. UNIX for Dummies Questions & Answers

Add a header to a sort file instruction

Hello, I have a header which I have to add to a sorted file, however if I use cat header sortedfile > newfile, the operation takes 2 minutes as the sorted file is over 400mb. I have noticed that when I sort the 400mb unsorted file, this only takes 14 seconds to create the output. As... (2 Replies)
Discussion started by: clarcombe
2 Replies

10. Shell Programming and Scripting

How to sort standard input without first line < Header >

Do somebody have idea How to sort standard input without first line which in my case it's header Example: Cnt|VT |STAT|Date |Time |From |Alert Message |Instance | 125| | | 260308 |160026 |ZAMUAT2|ifpollq... (8 Replies)
Discussion started by: pp56825
8 Replies
Login or Register to Ask a Question
SLABTOP(1)							Linux User's Manual							SLABTOP(1)

NAME
slabtop - display kernel slab cache information in real time SYNOPSIS
slabtop [options] DESCRIPTION
slabtop displays detailed kernel slab cache information in real time. It displays a listing of the top caches sorted by one of the listed sort criteria. It also displays a statistics header filled with slab layer information. OPTIONS
Normal invocation of slabtop does not require any options. The behavior, however, can be fine-tuned by specifying one or more of the fol- lowing flags: --delay=n, -d n Refresh the display every n in seconds. By default, slabtop refreshes the display every three seconds. To exit the program, hit q. --sort=S, -s S Sort by S, where S is one of the sort criteria. --once, -o Display the output once and then exit. --version, -V Display version information and exit. --help Display usage information and exit. SORT CRITERIA
The following are valid sort criteria used to sort the individual slab caches and thereby determine what are the "top" slab caches to dis- play. The default sort criteria is to sort by the number of objects ("o"). The sort criteria can also be changed while slabtop is running by pressing the associated character. a: sort by number of active objects b: sort by objects per slab c: sort by cache size l: sort by number of slabs v sort by number of active slabs n: sort by name o: sort by number of objects p: sort by pages per slab s: sort by object size u: sort by cache utilization COMMANDS
slabtop accepts keyboard commands from the user during use. The following are supported. In the case of letters, both cases are accepted. Each of the valid sort characters are also accepted, to change the sort routine. See the section SORT CRITERIA. <SPACEBAR> Refresh the screen. Q Quit the program. FILES
/proc/slabinfo slab information SEE ALSO
free(1), ps(1), top(1), vmstat(8) NOTES
Currently, slabtop requires a 2.4 or later kernel (specifically, a version 1.1 or later /proc/slabinfo). Kernel 2.2 should be supported in the future. The slabtop statistic header is tracking how many bytes of slabs are being used and it not a measure of physical memory. The 'Slab' field in the /proc/meminfo file is tracking information about used slab physical memory. AUTHORS
Written by Chris Rivera and Robert Love. slabtop was inspired by Martin Bligh's perl script, vmtop. The procps package is maintained by Albert Cahalan <albert@users.sf.net>. Please send bug reports to <procps-feedback@lists.sf.net>. Linux 13 Sep 2003 SLABTOP(1)