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
UUENCODE(5)							File Formats Manual						       UUENCODE(5)

NAME
uuencode - format of an encoded uuencode file DESCRIPTION
Files output by uuencode(1) consist of a header line, followed by a number of body lines, and a trailer line. The uudecode(1) command will ignore any lines preceding the header or following the trailer. Lines preceding a header must not, of course, look like a header. The header line is distinguished by having the first 6 characters begin The word begin is followed by a mode (in octal), and a string which names the remote file. A space separates the three items in the header line. The body consists of a number of lines, each at most 62 characters long (including the trailing newline). These consist of a character count, followed by encoded characters, followed by a newline. The character count is a single printing character, and represents an inte- ger, the number of bytes the rest of the line represents. Such integers are always in the range from 0 to 63 and can be determined by sub- tracting the character space (octal 40) from the character. Groups of 3 bytes are stored in 4 characters, 6 bits per character. All are offset by a space to make the characters printing. The last line may be shorter than the normal 45 bytes. If the size is not a multiple of 3, this fact can be determined by the value of the count on the last line. Extra garbage will be included to make the character count a multiple of 4. The body is terminated by a line with a count of zero. This line consists of one ASCII space. The trailer line consists of end on a line by itself. SEE ALSO
uuencode(1), uudecode(1), uusend(1), uucp(1), mail(1) HISTORY
The uuencode file format appeared in BSD 4.0 . UUENCODE(5)