[SOLVED] Why awk script will not output to file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [SOLVED] Why awk script will not output to file?
# 1  
Old 01-27-2014
[SOLVED] Why awk script will not output to file?

I have a script that looks like this:
Code:
for f in LISTDETAIL; do gawk -f script_0113b "$LISTDETAIL";done

It works perfectly, and I can see input on the screen. I have tried to redirect it to a file with the following techniques, but no luck:


Code:
for f in LISTDETAIL; do gawk -f script_0113b "$LISTDETAIL";done |tee file1

Code:
for f in LISTDETAIL; do gawk -f script_0113b "$LISTDETAIL";done>/tmp/file1

Code:
script for f in LISTDETAIL; do gawk -f script_0113b "$LISTDETAIL";done>/tmp/file1

I also started script on the command line and it would save nothing into a file. But I do know the script is working as I do see the desired input on the screen. Does any awk guru know why? Do I need to use "orint" with redirect, or is there something that needs to be done with the shell?
# 2  
Old 01-27-2014
I would have to actually see the awk program to know for sure, but it could be printing to standard error instead of standard output. In awk that would look like print "stuff" >"/dev/stderr"

You can redirect that with 2>filename
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 01-27-2014
You are a genius, many thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk and sed script to create one output CSV file

Hi All , I would require your help to generate one output file after post processing of one CSV file as stated below This file is just a small cut from a big file . Big file is having 20000 lines PATTERN,pat0,pat1,pat2,pat3,pat4,pat5,pat6,pat7,pat8,pat9... (2 Replies)
Discussion started by: kshitij
2 Replies

2. UNIX for Dummies Questions & Answers

[Solved] How to Redirect Output To Log File?

I have the below script, but when i execute it is still printing to screen is there a way i can stop this and just print everything to the log file. Thank you. #!/bin/bash exec > >(tee "/var/log/ScriptLogs/called_from_incrontab.log") 2>&1 DIR="$1" FILE="$2" echo "STEP 1: Datafile... (5 Replies)
Discussion started by: Ariean
5 Replies

3. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

4. UNIX for Dummies Questions & Answers

[Solved] awk output into a file

Hello board members.. here i am and here is my question. OS HP-UX awk i have a file where the FS is the pipe (|). So i choose the second field and i would like to do the following: If this filed is 0 then, i need the line in file1.txt Else write the line in file2.txt cat testfile.txt |... (2 Replies)
Discussion started by: kiko
2 Replies

5. Shell Programming and Scripting

Write Awk output to a file , inside script.

Hi, Can anyone please help me with this issue. I have a Awk command which take file as input, and provides the output having multiple lines, its working in command mode, but not if i plug it in script. #!/bin/ksh infile=a.txt outfile=b.txt awk ' BEGIN{ FS=OFS="|";ORS = "\n";... (1 Reply)
Discussion started by: sp999
1 Replies

6. Shell Programming and Scripting

[Solved] Output in bash script not captured in variable

I'm tring to write down a simple script that would execute a command and wait until it returns a specific result. This is what i did: bjobs_out=`bjobs` while ]; do bjobs_out=`bjobs` sleep 6 done It seems to work until the command 'jobs' return the list of jobs in execution, but... (4 Replies)
Discussion started by: lifedj
4 Replies

7. Shell Programming and Scripting

AWK Script to convert input file(s) to output file

Hi All, I am hoping someone can help me with some scripting I need to complete using AWK. I'm trying to process multiple fixed files to generate one concatenated fixed file in a standard format. The Input file is:- aaaa bbbbb ccccc 1 xxxx aaa bbb aaaa bbbbb ccccc 2 abcd aaa CCC... (9 Replies)
Discussion started by: jason_v_brown
9 Replies

8. Shell Programming and Scripting

Pass input and output file as parameter to awk script

Hi, i am new to awk. I am using csv2pipe script(shown below) BEGIN { FS=SUBSEP; OFS="|" } { result = setcsv($0, ",") print } # setcsv(str, sep) - parse CSV (MS specification) input # str, the string to be parsed. (Most likely $0.) # sep, the separator between the values. # #... (6 Replies)
Discussion started by: bhaskarjha178
6 Replies

9. Shell Programming and Scripting

awk script to search an html file and output links

hello. i want to make an awk script to search an html file and output all the links (e.g .html, .htm, .jpg, .doc, .pdf, etc..) inside it. also, i want the links that will be output to be split into 3 groups (separated by an empty line), the first group with links to other webpages (.html .htm etc),... (8 Replies)
Discussion started by: kyris
8 Replies

10. Shell Programming and Scripting

To parse through the file and print output using awk or sed script

suppose if u have a file like that Hen ABCCSGSGSGJJJJK 15 Cock ABCCSGGGSGIJJJL 15 * * * * * * : * * * . * * * : Hen CFCDFCSDFCDERTF 30 Cock CHCDFCSDHCDEGFI 30 * . * * * * * * * : * * :* : : . The output shud be where there is : and . It shud... (4 Replies)
Discussion started by: cdfd123
4 Replies
Login or Register to Ask a Question