Sponsored Content
Top Forums Shell Programming and Scripting bash ps; remove the header, sort and reinsert Post 302333231 by gekeha on Saturday 11th of July 2009 09:55:52 PM
Old 07-11-2009
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 header before the sort and reinsert it before the pipe to head.

Any help is appreciated.
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

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*/ (0 Replies)
Discussion started by: neil.0412
0 Replies

3. 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

4. Shell Programming and Scripting

sort a report file having header and footer

I am having report file with header and footer . The details in between header and footer are separated by a pipe charater. I want to sort the file by considering multiple columns in between header and footer. pls help (4 Replies)
Discussion started by: suryanarayana
4 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

Bash - remove duplicates without sort

I need to use bash to remove duplicates without using sort first. I can not use: cat file | sort | uniq But when I use only cat file | uniq some duplicates are not removed. (4 Replies)
Discussion started by: locoroco
4 Replies

7. 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

8. 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

9. 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

10. 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
NOWEB(1)						      General Commands Manual							  NOWEB(1)

NAME
noindex - build external index for noweb document SYNOPSIS
noindex basename[.tex] DESCRIPTION
noindex looks through LaTeX .aux files for identifiers that should go in a noweb external index. It sorts all identifiers and writes the results on basename.nwi. NOWEB INDEXING STRATEGIES
A noweb program consists of one or more files. In the simple case, these files are run through noweave together, to produce a single LaTeX file. noweave -index suffices to produce an index and cross-referencing information; neither nodefs nor noindex is required. When a noweb program consists of several source files, it is often better to run each source file through noweave to produce its own LaTeX file, then use noindex to produce an external index. This technique has several advantages: The line numbers in the LaTeX files correspond to the line numbers in the source files, so it is easier to diagnose LaTeX errors. The LaTeX includeonly feature can be used, making it possible to format parts of large programs while retaining complete cross-ref- erence information. When used with make(1), the technique avoids running noweave over source files that have not changed. Using the external index places fewer demands on LaTeX's memory, making it read its .aux files much more quickly. The disadvantages are that nodefs and noindex are needed for full cross-referencing and a properly sorted index. EXAMPLE
This example assumes a noweb program of three source files: a.nw , b.nw , and c.nw. The file doc.tex is assumed to contain LaTeX boiler- plate, including the commands oweboptions{externalindex} include{a} include{b} include{c} The first sequence of steps is to create a file listing all the identifiers defined anywhere in a, b, or c. nodefs a.nw > a.defs nodefs b.nw > b.defs nodefs c.nw > c.defs sort -u a.defs b.defs c.defs | cpif all.defs Using sort -u and cpif(1) avoids changing all.defs unless the set of identifiers changes. This technique, used in a Makefile, avoids unnecessary rebuilding. The next series of steps is to create LaTeX files with full cross-reference information for all identifiers. noweave -n -indexfrom all.defs a.nw > a.tex noweave -n -indexfrom all.defs b.nw > b.tex noweave -n -indexfrom all.defs c.nw > c.tex The final steps run LaTeX once to create .aux files, then noindex to create the index, then LaTeX again to format the complete document. latex doc noindex doc latex doc In a Makefile, noindex can be run before every invocation of LaTeX. BUGS
noindex is distributed in awk and Icon versions. The awk version is slow and does a poorer job sorting. There is no comparable machinery to make it possible to use multiple files with the HTML back end. SEE ALSO
noweave(1), nodefs(1), cpif(1) VERSION
This man page is from noweb version 2.11b. AUTHOR
Norman Ramsey, Harvard University. Internet address nr@eecs.harvard.edu. Noweb home page at http://www.eecs.harvard.edu/~nr/noweb. local 3/28/2001 NOWEB(1)
All times are GMT -4. The time now is 04:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy