Sponsored Content
Top Forums Shell Programming and Scripting help with awk with changing parameters: TY Post 302577120 by calim_cfd on Monday 28th of November 2011 10:48:35 AM
Old 11-28-2011
posting a larger part of the code...

#!/bin/bash
...
....
for ff in `seq 3 $nlpN`;
do
npc1[$ff]=`awk 'NR=='$ff' {print $1}' p_walls.raw| cut -f1 -d ' '`; echo ${npc1[$ff]};
npc2[$ff]=`awk 'NR=='$ff' {print $2}' p_walls.raw| cut -f1 -d ' '`;
npc3[$ff]=`awk 'NR=='$ff' {print $3}' p_walls.raw| cut -f1 -d ' '`;
npRs[$ff]=`awk 'NR=='$ff' {print $4}' p_walls.raw| cut -f1 -d ' '`;
echo $ff
done

...
...
...


you see... i got LOTS of awks.. and the input files..they got like 70k and 30k lines to be read... so i got 70k*30k passes..

the awks make this scrip run in 22years with a decent pc... so i figure if i could use sth like balaje pointed.. sth like

fopen
...
fclose;

using perl i guess ill need to work with 2 shells and i need all variables on the memory so speed thing up Smilie

so far using perl is the way... not too happy about moving.. and the script is not finished yet..got add more conditionals and debugg/cleanup..etc

---------- Post updated at 10:48 AM ---------- Previous update was at 08:46 AM ----------

i guess i may have found an answer in another forumSmilie:
Code:
for ff in `seq 3 $nlpN`
do
    data=`awk 'NR=='$ff' { print $1, $2, $3, $4; exit }' p_walls.raw`
    npc1[$ff]=`echo "$data" | cut -f1 -d ' '`
    echo ${npc1[$ff]}
    npc2[$ff]=`echo "$data"`
    npc3[$ff]=`echo "$data"`
    npRs[$ff]=`echo "$data"`
    echo $ff
done

any comments

ty again!Smilie

Last edited by vbe; 11-28-2011 at 01:10 PM.. Reason: removed parts of the code that were useless here
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing TCP parameters in solaris10

Hi I have to change some TCP settings in Solaris10 machine running on AMD. Is there any tool or GUI to do this. I want to see if there is any easy way to put them in the startup scripts. Thanks (1 Reply)
Discussion started by: sssow
1 Replies

2. Shell Programming and Scripting

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 (3 Replies)
Discussion started by: jacma
3 Replies

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

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

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

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

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

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

9. HP-UX

Changing Dynamic Tunable parameters in the kernel

To fix an "issue" we're having I need to update SHMMAX from 1GB to 2Gb, it's a dynamic parameter so am just wondering how flexible it really is. As Oracle is running on the server do I need to shut that down to change the parameter or will it just take the change on the fly? Also how would I... (6 Replies)
Discussion started by: Turlock
6 Replies

10. 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
print(1)							   User Commands							  print(1)

NAME
print - shell built-in function to output characters to the screen or window SYNOPSIS
ksh print [ -Rnprsu [n]] [arg...] DESCRIPTION
ksh The shell output mechanism. With no flags or with flag - or -, the arguments are printed on standard output as described by echo(1). OPTIONS
The following options are supported: -n suppresses new-line from being added to the output. -R -r (raw mode) ignore the escape conventions of echo. The -R option will print all subsequent arguments and options other than -n. -p causes the arguments to be written onto the pipe of the process spawned with |& instead of standard output. -s causes the arguments to be written onto the history file instead of standard output. -u [ n ] flag can be used to specify a one digit file descriptor unit number n on which the output will be placed. The default is 1. EXIT STATUS
The following exit values are returned: 0 Successful operation. >0 Output file is not open for writing. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
echo(1), ksh(1), attributes(5) SunOS 5.10 15 Apr 1994 print(1)
All times are GMT -4. The time now is 05:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy