Sponsored Content
Top Forums Shell Programming and Scripting awk print header as text from separate file with getline Post 302582001 by sdf on Wednesday 14th of December 2011 04:46:38 PM
Old 12-14-2011
awk print header as text from separate file with getline

I would like to print the output beginning with a header from a seperate file like this:

Code:
awk 'BEGIN{FS="_";print ((getline < "header.txt")>0)} { if (! ($0 ~ /EL/ )  print }" input.txt

What am i doing wrong?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - getline from parametric file name

Hi! I have an input file for an awk script that I need to split into several files and the process them separately line by line. I have splitted the input file into the other files, that have been created correctly. But, since their names are parametric (i.e. output_1.txt, output_2.txt..... (2 Replies)
Discussion started by: Alice236
2 Replies

2. Shell Programming and Scripting

Need awk help to print specific columns with as string in a header

awk experts, I have a big file of 4000 columns with header. Would like to print the columns with string value of "Commands" in header. File has "," separator. This file is on ESX host with Bash. Thanks, Arv (21 Replies)
Discussion started by: arv_cds
21 Replies

3. Shell Programming and Scripting

awk/sed script to print each line to a separate named file

I have a large 3479 line .csv file, the content of which looks likes this: 1;0;177;170;Guadeloupe;x 2;127;171;179;Antigua and Barbuda;x 3;170;144;2;Umpqua;x 4;170;126;162;Coos Bay;x ... 1205;46;2;244;Unmak Island;x 1206;47;2;248;Yunaska Island;x 1207;0;2;240;north sea;x... (5 Replies)
Discussion started by: kalelovil
5 Replies

4. Shell Programming and Scripting

awk getline t file

I want to import a textfile with getline into var t which has several lines. How do import all lines, since it only imports the last line: while < ((getline t "textfile") > 0) (7 Replies)
Discussion started by: sdf
7 Replies

5. Shell Programming and Scripting

awk: Print fields between two delimiters on separate lines and send to variables

I have email headers that look like the following. In the end I would like to accomplish sending each email address to its own variable, such as: user1@domain.com='user1@domain.com' user2@domain.com='user2@domain.com' user3@domain.com='user3@domain.com' etc... I know the sed to get rid of... (11 Replies)
Discussion started by: tay9000
11 Replies

6. Shell Programming and Scripting

awk getline 8 times and if $3 = 8 when subtracted from 1st line,print

I have kind of a strange one here. I have a file of consecutive /24 ip blocks. If there are 8 consecutive ip blocks which represent a /20 then I need to print the first line. I played around and did not get the results I need, especially when considering that the highest $3 will be is 255 and then... (6 Replies)
Discussion started by: numele
6 Replies

7. Programming

Read text from file and print each character in separate line

performing this code to read from file and print each character in separate line works well with ASCII encoded text void preprocess_file (FILE *fp) { int cc; for (;;) { cc = getc (fp); if (cc == EOF) break; printf ("%c\n", cc); } } int main(int... (1 Reply)
Discussion started by: khaled79
1 Replies

8. Shell Programming and Scripting

awk to print line is values between two fields in separate file

I am trying to use awk to find all the $3 values in file2 that are between $2 and $3 in file1. If a value in $3 of file2 is between the file1 fields then it is printed along with the $6 value in file1. Both file1 and file2 are tab-delimited as well as the desired output. If there is nothing to... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. Shell Programming and Scripting

Print header and lines that meet both conditions in awk

In the awk below I am trying to print only the header lines starting with # or ## and the lines that $7 is PASS and AF= is less than 5%. The awk does execute but returns an empty file and I am not sure what I am doing wrong. Thank you. file ... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
GETINFO(1)						      General Commands Manual							GETINFO(1)

NAME
getinfo - get header information from a RADIANCE file SYNOPSIS
getinfo [ -d ][ file .. ] getinfo - DESCRIPTION
Getinfo reads the header of each RADIANCE file and writes it to the standard output. Octree and picture files are in a binary format, which makes it difficult to determine their content. Therefore, a few lines of text are placed at the beginning of each file by the RADI- ANCE program that creates it. The end of the header information and the start of the data is indicated by an empty line. The -d option can be used to print the dimensions of an octree or picture file instead. For an octree, getinfo -d prints the bounding cube (xmin ymin zmin size). For a picture, getinfo -d prints the y and x resolution (-Y yres +X xres). If no file is given, the standard input is read. The second form of getinfo with a hyphen simply removes the header and copies the body of the file from the standard input to the standard output. EXAMPLE
To print the header information from scene1.oct and scene2.hdr: getinfo scene1.oct scene2.hdr AUTHOR
Greg Ward SEE ALSO
oconv(1), pfilt(1), rhinfo(1), rpict(1), rvu(1) RADIANCE
1/15/99 GETINFO(1)
All times are GMT -4. The time now is 10:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy