Dynamic filename in awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dynamic filename in awk
# 1  
Old 01-23-2007
Java Dynamic filename in awk

Hi

The following code seems to work, but why am i getting an error message?

Code:
cscyabl@comet:(develop)> awk 'BEGIN {FS="|"}{print $2 >> $1}' test.sum    
awk: A print or getline function must have a file name.
 The input line number is 8. The file is test.sum.
 The source line number is 1.

Cheers
# 2  
Old 01-23-2007
I think $1 might be a null string.
# 3  
Old 01-23-2007
Right, thanks anbu23, there was such a blank line in my file. Wasn't obvious since the file is really big... Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Executing if dynamic conditions in awk

Hi All, I got struck at the below point where i am unable to get the desired output after forming the dynamic conditions.Below is the design. 1. We are getting inputs from the shell arguments and storing in a variable like below. CONDITIONS="1=CT,2=US_10,3=CT_US_10" 2. After this i am... (14 Replies)
Discussion started by: cskumar
14 Replies

2. Shell Programming and Scripting

Using awk add preffic to dynamic order

Source file portIndex: 75 portName: slot9 port11 c0:50:96:05:9f:f2:00:f2 c0:50:96:05:9f:f2:00:ea c0:50:96:05:9f:f2:01:13 c0:50:96:05:9f:f2:01:12 c0:50:96:05:9f:f2:01:0b c0:50:96:05:9f:f2:01:0a c0:50:96:05:9f:f2:01:03 ... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

3. UNIX for Dummies Questions & Answers

awk : dynamic output flatfile filename

Hello, I'm using the awk command to insert empty columns on a tab delimited flatfile - which works fine - => But I'm not able to manage dynamicaly the filename of the awk output based on the source flatfile filename I have 3 source flatfile: flatfile_Jan-2016.csv flatfile_Feb-2016.csv... (3 Replies)
Discussion started by: Tipiak
3 Replies

4. Shell Programming and Scripting

Modify line with dynamic variable in awk

Hi, I'm guessing this is probably relatively straight forward to do in awk, but I just can't get my head round it! I have a log file of the following format: 3:03:35 (lmgrd) TIMESTAMP 10/14/2011 3:20:41 (MLM) IN: "MATLAB" user1@host1.private.dns.zone 3:21:05 (MLM) IN: "MATLAB"... (2 Replies)
Discussion started by: chrissycc
2 Replies

5. Shell Programming and Scripting

how to make pattern search dynamic in awk

Hi, I have a data in a file like below - andy 22 abc 30000 wallstreet paul 30 xyz 40000 martstreet john 35 abc 50000 martstreet I want to search number of employees working in a particular company. Below query executes perfectly - awk '/abc/{ COUNT ++; }END { print "number of... (3 Replies)
Discussion started by: shell123
3 Replies

6. Shell Programming and Scripting

Dynamic command line generation with awk

Hi, I'm not an expert in awk but i need a simple script to do this: I'd like to AutoCrop PDF files. I found 2 simple script that combined together could help me to automatize :) The first utiliti is "pdfinfo" that it gives the MediaBox and TrimBox values from the pdf. The pdfinfo output... (8 Replies)
Discussion started by: gbagagli
8 Replies

7. Shell Programming and Scripting

How to use a dynamic filename with sed?

I have a line that works for static filename cat /directorypath/filename | sed '//d;//d' > filename This approach when used in a script works well. Then i need a list of filenames to give this line. I can get the list into a file by filelist1='ls -m' then use filelist2=${filelist1##ls... (4 Replies)
Discussion started by: ericonanson
4 Replies

8. Shell Programming and Scripting

gzcat into awk and then change FILENAME and process new FILENAME

I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
Discussion started by: timj123
6 Replies

9. UNIX for Advanced & Expert Users

dynamic match thru awk

hey , my i/p text looks like this, FILE_TYPE=01|FILE_DESC=Periodic|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=B FILE_TYPE=02|FILE_DESC=NCTO|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=M NOTE Look carefully for the position FILE_TYPE,FILE_DESC... (23 Replies)
Discussion started by: manas_ranjan
23 Replies

10. UNIX for Dummies Questions & Answers

Parsing XML dynamic data via awk?

I am trying to use a line of output in an XML file as input in another new XML file for processing purposes via a shell script. Since I am a newbie though, I'm not sure how to do this since the data is different everytime. I am using this technique with static data right now: echo -n "Running... (5 Replies)
Discussion started by: corwin43
5 Replies
Login or Register to Ask a Question