Sponsored Content
Full Discussion: Awk issue
Top Forums Shell Programming and Scripting Awk issue Post 302192998 by potro on Thursday 8th of May 2008 08:36:18 AM
Old 05-08-2008
Quote:
Originally Posted by Franklin52
Use a loop, something like:

Code:
grep "^Listen" httpd.conf | awk '{print $2}'| 
while read var 
do
  # do something with $var
done

Regards
Thanks for the solution.

Now if I can continue with my issue:
I have read a number of 5 variables: LISTEN_PORT1, LISTEN_PORT2, LISTEN_PORT3, LISTEN_PORT4, LISTEN_PORT5

The file looks like this:
...
Listen FrontEnd_1_IP:8081
Listen FrontEnd_2_IP:8081
Listen 8081
Listen 8082
Listen 8083
....

I need to replace those values with the variables
Listen $LISTEN_PORT1
Listen $LISTEN_PORT2
etc

And another issue is that the number of the parameters in the file can be less or greater that the number of the variable but in the file I need to add al least this variables and ignore the rest.

Thanks a lot
Bianca
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk issue

Can someone please explain below code. $LIST|awk ' /^$/ { next } substr($0,1,4)=="Exiting" { mk = 1; next } mk==1 { print $3,$7,$10,$14; exit } Cheers, gehlnar (5 Replies)
Discussion started by: gehlnar
5 Replies

2. Shell Programming and Scripting

Issue in awk

In the following code, Im trying to imbed many statements in a single awk statement. But it gives an error on that, for i in `less usage_types_dwh.txt` do cd /u01/app/evident/analysis_lab/usg_type grep $i svc_type.txt | head -1 | awk 'BEGIN {FS=","} {print $1 "==" $2 ":" $3 ":" $4;... (2 Replies)
Discussion started by: alishehzadpaul
2 Replies

3. Shell Programming and Scripting

Issue with AWK

I have this input file 0FB7,1083,Synchronized,FriNov121655,2816_7RAID5,05F:1_10F:1,10000000NoneNone,DC_db00p01 0FB7,1150,Split,MonApr180658,2816_7R5GC,N/A,N/A,N/A 06C4,0710,Synchronized,WedMar91105,2816_7RAID5,04E:1_11E:1,10000000NoneNone,DL_nb00p25... (1 Reply)
Discussion started by: greycells
1 Replies

4. Shell Programming and Scripting

awk NR issue

Hi guys, i am trying to analyze a text file using awk and am not able to solve this issue. This is the piece of code that I have written BEGIN { ## Time to count MACs -> 5 seconds. TIME_LIMIT = 5; k = 50000; } ## For every line. { time_in_seconds = $1... (2 Replies)
Discussion started by: jamie_123
2 Replies

5. Shell Programming and Scripting

AWK Issue

Hey, this is my code, cat $fulltrpath | while read line do inputfile=$(sed 1q $fulltrpath | awk '{ FS = "\t"; print $2$1}') outputpath=$(sed 1q $fulltrpath | awk '{ FS = "\t"; print $3 }') echo $inputfile echo $outputpath cp $inputfile $outputpath let path++ done if i... (1 Reply)
Discussion started by: inshafccna
1 Replies

6. Shell Programming and Scripting

issue trying to use awk

Hi Gurus, I am facing a similar issue usiung an awk command. Below is my requirement: ---DATA--- A;F;G A;D;E A;D;E B;Z;P C;Z;Q Expected: A F<TAB>G D<TAB>E D<TAB>E B D<TAB>E (1 Reply)
Discussion started by: rajangupta2387
1 Replies

7. Shell Programming and Scripting

awk issue

Hi all, i am trying to use below command to see the output of hardware inventory, but i only see 2 first line no output of the command. awk '/Hardware/ {print $0}' XXX_result.txt Hardware inventory: Hardware inventory: any idea how to see whatever is under hardware inventory. i... (11 Replies)
Discussion started by: Jared
11 Replies

8. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

9. Shell Programming and Scripting

awk - issue to get the right IP

On AIX 5.3 and AIX 6.1, I have this script for checking printers being pingable or not. for i in `lsallq` do echo "Queue Name: " $i echo "----------------------------------------" for j in `lsallqdev -q $i` do echo " Device Name:" $j hname=`echo... (3 Replies)
Discussion started by: Daniel Gate
3 Replies

10. UNIX for Dummies Questions & Answers

Help with awk issue

OK, so I am trying to use awk as a method of accessing a table stored in a file to then provide the capability of a look up table. The table is stored in a file named "/Users/jhaney/Desktop/assetTypeMapping.tsv" and looks like this: aCategory aLetter aNumber AssetCat1 A 123 ... (10 Replies)
Discussion started by: jhaneyzz
10 Replies
SYSTEMD-SOCKET-ACTIVATE(1)				      systemd-socket-activate					SYSTEMD-SOCKET-ACTIVATE(1)

NAME
systemd-socket-activate - Test socket activation of daemons SYNOPSIS
systemd-socket-activate [OPTIONS...] daemon [OPTIONS...] DESCRIPTION
systemd-socket-activate may be used to launch a socket-activated service program from the command line for testing purposes. It may also be used to launch individual instances of the service program per connection. The daemon to launch and its options should be specified after options intended for systemd-socket-activate. If the --inetd option is given, the socket file descriptor will be used as the standard input and output of the launched process. Otherwise, standard input and output will be inherited, and sockets will be passed through file descriptors 3 and higher. Sockets passed through $LISTEN_FDS to systemd-socket-activate will be passed through to the daemon, in the original positions. Other sockets specified with --listen= will use consecutive descriptors. By default, systemd-socket-activate listens on a stream socket, use --datagram and --seqpacket to listen on datagram or sequential packet sockets instead (see below). OPTIONS
-l address, --listen=address Listen on this address. Takes a string like "2000" or "127.0.0.1:2001". -a, --accept Launch an instance of the service program for each connection and pass the connection socket. -d, --datagram Listen on a datagram socket (SOCK_DGRAM), instead of a stream socket (SOCK_STREAM). May not be combined with --seqpacket. --seqpacket Listen on a sequential packet socket (SOCK_SEQPACKET), instead of a stream socket (SOCK_STREAM). May not be combined with --datagram. --inetd Use the inetd protocol for passing file descriptors, i.e. as standard input and standard output, instead of the new-style protocol for passing file descriptors using $LISTEN_FDS (see above). -E VAR[=VALUE], --setenv=VAR[=VALUE] Add this variable to the environment of the launched process. If VAR is followed by "=", assume that it is a variable-value pair. Otherwise, obtain the value from the environment of systemd-socket-activate itself. --fdname=NAME[:NAME...] Specify names for the file descriptors passed. This is equivalent to setting FileDescriptorName= in socket unit files, and enables use of sd_listen_fds_with_names(3). Multiple entries may be specifies using separate options or by separating names with colons (":") in one option. In case more names are given than descriptors, superfluous ones will be ignored. In case less names are given than descriptors, the remaining file descriptors will be unnamed. -h, --help Print a short help text and exit. --version Print a short version string and exit. ENVIRONMENT VARIABLES
$LISTEN_FDS, $LISTEN_PID, $LISTEN_FDNAMES See sd_listen_fds(3). $SYSTEMD_LOG_TARGET, $SYSTEMD_LOG_LEVEL, $SYSTEMD_LOG_COLOR, $SYSTEMD_LOG_LOCATION Same as in systemd(1). EXAMPLES
Example 1. Run an echo server on port 2000 $ systemd-socket-activate -l 2000 --inetd -a cat Example 2. Run a socket-activated instance of systemd-journal-gatewayd(8) $ systemd-socket-activate -l 19531 /lib/systemd/systemd-journal-gatewayd SEE ALSO
systemd(1), systemd.socket(5), systemd.service(5), sd_listen_fds(3), sd_listen_fds_with_names(3), cat(1) systemd 237 SYSTEMD-SOCKET-ACTIVATE(1)
All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy