awk - printing parameters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk - printing parameters
# 1  
Old 07-02-2008
awk - printing parameters

Hello

I've got a script that takes 2 parameters. id and f.
id is a user id and f is a file.
I want to print this id on the first line and then the file.

how can this be done?

thanks
# 2  
Old 07-02-2008
Code:
FNR==1 { print id ORS f }

# the rest of the awk script...

# 3  
Old 07-02-2008
The basic:
Code:
#!/bin/sh
awk -v id=$1 'NR==1{print id;next}{print}' $2

Stop asking & start learning, in the same time you can search the forum.
# 4  
Old 07-04-2008
thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pass Parameters to awk command

I need to pass values at runtime for the below awk command where l is the length and partial.txt is the file name. awk -v l=285 '{s="%-"l"s\n";printf(s,$0);}' partial.txt > temp1.txt; (5 Replies)
Discussion started by: Amrutha24
5 Replies

2. Shell Programming and Scripting

help with awk with changing parameters: TY

hi, i got several pieces of code that look like: for ff in `seq 3 $nlpN`; do npc1=`awk 'NR=='$ff' {print $1}' p_walls.raw`; echo ${npc1}; npc2=`awk 'NR=='$ff' {print $2}' p_walls.raw`; npc3=`awk 'NR=='$ff' {print $3}' p_walls.raw`; npRs=`awk 'NR=='$ff' {print $4}'... (10 Replies)
Discussion started by: calim_cfd
10 Replies

3. Shell Programming and Scripting

Search parameters on file with AWK

Hello everyone!! I need help with this please: I have a file with this content: 56977964333 730030201857822 1 2 4 56976969284 730030201412442 1 2... (3 Replies)
Discussion started by: bobbasystem
3 Replies

4. Shell Programming and Scripting

Help with explanation of awk parameters

Hello, Would someone be able to tell me exactly how this command works please? awk '!x++' As usual any help much appreciated (8 Replies)
Discussion started by: Grueben
8 Replies

5. Shell Programming and Scripting

Remove certain parameters from column using awk or sed

I have a text file Nov 1 LOG_10_000000343.gzip_COMPLETE 2910 server.log.3 Nov 4 LOG_10_000000343.gzip_COMPLETE 2910 server.log.4 Dec 5 LOG_10_000000343.gzip_blah 2910 server.log.5 Jul 6 LOG_10_000000343.gzip_ERROR 2910 server.log.1 I need to convert this to Nov 1 LOG_10_000000343.gzip... (3 Replies)
Discussion started by: gubbu
3 Replies

6. Shell Programming and Scripting

passing parameters using awk

Hi, The below script is working fine awk1.sh ======= awk BEGIN { FS="|" } FNR==NR { f1=$2; next } $1 in f1 && $2 =="xx" && $1 == "DAILY_JOB" {print $3} awk -f awk1.sh a.txt b.txt--Its working fine . When passing parameters its not working .Any help it should be appereciated. ... (4 Replies)
Discussion started by: akil
4 Replies

7. Shell Programming and Scripting

awk parameters check

Is there a way to preform check if the parameters that was send with the command awk -f `file_name.awk` `input_file` before even it gets to the BEGIN section (i have tested a try to check in the BEGIN it doesn't let ,you must make it on the section that after the BEGIN) and then decide if the... (1 Reply)
Discussion started by: tal
1 Replies

8. Shell Programming and Scripting

AWK alias with parameters

Hello, How can I make an alias of an AWK one liner that prints specific lines from a file like below? # from a command like this: awk 'NR == 100, NR == 150' file.cfg The alias I want to make should work like this(I guess): <alias_command> <file.cfg><start_line><end_line> So the... (1 Reply)
Discussion started by: majormark
1 Replies

9. Shell Programming and Scripting

How to pass parameters to an awk file?

I have an awk file where I need to pass a filename and a value as a parameter from a sh script. I need to know how to pass those values in the sh script and how to use the same in the awk file. Thanks in advance!!! Geetha (3 Replies)
Discussion started by: iamgeethuj
3 Replies

10. Shell Programming and Scripting

printing parameters from .profile

Hi, I have defined a few parameters in .profile. Here is how it looks like.. export ABC_HOME=/vol.nas/b20/abc/13.0/nm53/abc-13.0 export RFX_TMP=/vol.def/u50/abc/13.0/nm456/abc-13.0/tmp export SQLPATH=:/dba/sql export TEST_ABC_INTEGRATION_HOME=/home/txt/lms export... (3 Replies)
Discussion started by: neeto
3 Replies
Login or Register to Ask a Question