Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Sort a las file keep the header as it is Post 302955023 by MadeInGermany on Monday 14th of September 2015 08:31:45 AM
Old 09-14-2015
More efficient with awk:
Code:
for file in *.las
do
  awk '(sort==1) {print | "sort -k1,1n"; next} ($1~/^~Version/) {sort=1} {print}' "$file" > "$file.$$" &&
  cp "$file.$$" "$file" &&
  rm -f "$file.$$"
done

Would be even shorter with perl, thanks to its -i option and internal sort.

Last edited by MadeInGermany; 09-14-2015 at 09:41 AM.. Reason: use the precise sort option
These 2 Users Gave Thanks to MadeInGermany For This Post:
 

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

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

Ignore Header and Footer and Sort the data in fixed width file

Hi Experts, I want to Sort the data in fixed width file where i have Header and Footer also in file. I m using below commad to do the sort based on field satarting from 15 position to 17 position , but it is not ignoring the Header and Footer of the file while sorting. In the output i am... (5 Replies)
Discussion started by: sasikari
5 Replies

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

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

7. UNIX for Dummies Questions & Answers

How can i sort a .txt file without loosing the header information?

Hi, I'm trying to sort 2 different .txt tab delimited files with the command line: sort -k 1b,1 inputfile > outputfile But doing that i'm also sorting the header (that ends at the end of my file). How can i sort a .txt file without sorting the header but conserving the header in the... (3 Replies)
Discussion started by: alisrpp
3 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: ------------------------------------------------------------------------- Code: ~Version .....text.... ~Ascii 2 abc 230 1 name 1 abc ... (1 Reply)
Discussion started by: tk2000
1 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
2L(1)							      General Commands Manual							     2L(1)

NAME
2l, 6l, 8l, kl, vl, xl - loaders SYNOPSIS
2l [ option ... ] [ file ... ] 6l [ option ... ] [ file ... ] 8l [ option ... ] [ file ... ] kl [ option ... ] [ file ... ] vl [ option ... ] [ file ... ] xl [ option ... ] [ file ... ] DESCRIPTION
2l, 6l, 8l, kl, vl, and xl load the named files into MC68020, i960, i386, SPARC, MIPS, and ATT3210 executable files. The files should be object files or libraries (archives of object files) for the appropriate architecture. Also, a name like -lext represents the library libext.a in /$objtype/lib, where objtype is one of 68020, 960, 386, sparc, mips, or 3210. The libraries must have tables of contents (see ar(1)). In practice, -l options are rarely necessary as the header files for the libraries cause their archives to be included automatically in the load (see 2c(1)). For example, any program that includes header file libc.h causes the loader to search the C library /$obj- type/lib/libc.a. Also, the loader creates an undefined symbol _main (or _mainp if profiling is enabled) to force loading of the startup linkage from the C library. The order of search to resolve undefined symbols is to load all files and libraries mentioned explicitly on the command line, and then to resolve remaining symbols by searching in topological order libraries mentioned in header files included by files already loaded. When scanning such libraries, the algorithm is to scan each library repeatedly until no new undefined symbols are picked up, then to start on the next library. Thus if library A needs B which needs A again, it may be necessary to mention A explicitly so it will be read a second time. The loader options are: -l (As a bare option.) Suppress the default loading of the startup linkage and libraries specified by header files. -o out Place output in file out. Default is O.out, where O is the first letter of the loader name. -p Insert profiling code into the executable output; no special action is needed during compilation or assembly. -s Strip the symbol tables from the output file. -a Print the object code in assembly language, with addresses. -v Print debugging output that annotates the activities of the load. -cfunction (Xl only) Place the function in the internal RAM of the DSP3210. -M (Kl only) Generate instructions rather than calls to emulation routines for multiply and divide. -msize (Xl only) Use size (default 0, maximum 8192) bytes of internal RAM of the DSP3210 for functions and small data items. -Esymbol The entry point for the binary is symbol (default _main; _mainp under -p). -Hn Executable header is type n. The meaning of the types is architecture-dependent; typically type 1 is Plan 9 boot format and type 2 is the regular Plan 9 format, the default. These are reversed on the MIPS. The Next boot format is 3. Type 4 in vl creates a MIPS executable for an SGI Unix system. -Tt The text segment starts at address t. -Dd The data segment starts at address d. -Rr The text segment is rounded to a multiple of r (if r is nonzero). The numbers in the above options can begin with or to change the default base from decimal to hexadecimal or octal. The defaults for the values depend on the compiler and the header type. The loaded image has several symbols inserted by the loader: etext is the address of the end of the text segment; bdata is the address of the beginning of the data segment; edata is the address of the end of the data segment; and end is the address of the end of the bss seg- ment, and of the program. FILES
/$objtype/lib for -llib arguments. SOURCE
/sys/src/cmd/2l etc. SEE ALSO
2c(1), 2a(1), alef(1), ar(1), nm(1), db(1), prof(1) Rob Pike, ``How to Use the Plan 9 C Compiler'' 2L(1)
All times are GMT -4. The time now is 12:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy