Get vaule and from file and need to run in loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get vaule and from file and need to run in loop
# 1  
Old 10-20-2015
Get vaule and from file and need to run in loop

Hi All,

I have a command which provide this output

Code:
symaccess -sid 624 show PG_E36_PG6P -type port |grep FA
       FA-5G:1
       FA-6G:0
       FA-11G:0
       FA-12G:1

I need to use the value in loop like this

Quote:

symcfg -sid 624 list -fa 5G -p 1 -address >> info.txt
symcfg -sid 624 list -fa 6G -p 0 -address >> info.txt
symcfg -sid 624 list -fa 11G -p 0 -address >> info.txt
symcfg -sid 624 list -fa 12G -p 1 -address >> info.txt
# 2  
Old 10-20-2015
Not clear. Be way more specific and detailed.
# 3  
Old 10-20-2015
I want to get the value from first command from the output i need only the

Quote:
for FA-5G:1 i need to get only the below value and run in loop and export to file
5g and 1

to run this command in loop

Quote:
symcfg -sid XXX list -fa 5G -p 1 -address
# 4  
Old 10-20-2015
The data as you show it contains spaces before each value. I will then take this and put it in a file called file3.
Code:
       FA-5G:1
       FA-6G:0
       FA-11G:0
       FA-12G:1

sed -n 's/FA-\(.*G\):\(.$\)/symcfg -sid 624 list -fa \1 -p \2 -address >> info.txt/p' file3

symcfg -sid 624 list -fa 5G -p 1 -address >> info.txt
symcfg -sid 624 list -fa 6G -p 0 -address >> info.txt
symcfg -sid 624 list -fa 11G -p 0 -address >> info.txt
symcfg -sid 624 list -fa 12G -p 1 -address >> info.txt

These would be run consecutively.
Does that approximate the required result?
# 5  
Old 10-20-2015
Try also
Code:
 $(symaccess -sid 624 show PG_E36_PG6P -type port | awk '/FA/ {print "symcfg -sid 624 list -fa " $2 " -p " $3 " -address >> info.txt"}' FS="[-:]")

---------- Post updated at 16:30 ---------- Previous update was at 15:36 ----------

Disregard above. Try
Code:
symaccess -sid 624 show PG_E36_PG6P -type port | awk '/FA/ {print "symcfg -sid 624 list -fa " $2 " -p " $3 " -address >> info.txt"}' FS="[-:]" | sh

# 6  
Old 10-20-2015
thank RudiC it solve my issue
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run a loop that will search for a file to thousand machine and know who owns the file

Run a loop that will search for a file to thousand machine and know who owns the file $ for i in abc{01..02} > do > echo -n $i > ssh $i "sudo find / -name .ssh -exec ls -l {} \;|grep id" > done abc01-rw-------. 1 root root 1675 Nov 10 2018 id_rsa abc01-rw-------. 1 root root 1675 Nov 14... (6 Replies)
Discussion started by: invinzin21
6 Replies

2. Shell Programming and Scripting

Getting RSSI Vaule from shell

'm trying to get the TxPower(RSSI) Value of an iBeacon (BEACONinside, ModelNo. B0001-A) and I'm struggling to get this value into a Python-, C- or Shellscript. I looked through many Tutorials and Stackoverflow Questions, but (since BLE is quiet new) I'm not able to find anything to start with. ... (1 Reply)
Discussion started by: Reficul
1 Replies

3. Shell Programming and Scripting

How to run it in the loop??

I have this code awk -F, ' { C5+=$5 C6+=$6 C7+=$7 C8+=$8 R=$5+$6+$7+$8 T+=R } { print $0,R } END { print... (7 Replies)
Discussion started by: nikhil jain
7 Replies

4. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

5. Shell Programming and Scripting

Run script to export the data to ixf file in loop

Hi, I am trying to export the data to an .ixf file. I have read the table names from a .dat file and those table name should be passed to the select * from schema.TABLENAME query . I am trying the below loop while read TABLE; do db2 EXPORT TO ~/data_export/$TABLE.ixf OF IXF MESSAGES... (5 Replies)
Discussion started by: vikyalex4
5 Replies

6. Shell Programming and Scripting

Need help to run query in loop for all acct nbr in a file..

I have a txt file with contents of acct nbr's like: 22222222222 33333333333 33445566778 I need to write a script which takes each acct nbr in the file and run the query like: select seq_nbr from event where acct_nbr='22222222222' and the query's output should be passed to a... (2 Replies)
Discussion started by: Rajesh Putnala
2 Replies

7. Shell Programming and Scripting

Need help to run query in loop for all acct nbr in a file..

I have a txt file with contents of acct nbr's like: 22222222222 33333333333 33445566778 I need to write a script which takes each acct nbr in the file and run the query like: select seq_nbr from event where acct_nbr='22222222222' and the query's output should be passed to a... (0 Replies)
Discussion started by: Rajesh Putnala
0 Replies

8. Shell Programming and Scripting

How To Run A For Loop In A Remsh?

Hi all, I'm trying to remsh to another server and then execute a for loop command there but I'm getting unexpected errors and would appreciate any suggestions. Ideally what I want to do is this: for host in `cat host_file` do remsh $host -n " cd /home/ for DATABASE in `ls -d... (5 Replies)
Discussion started by: Korn0474
5 Replies

9. Shell Programming and Scripting

Is there a better way I could have run this loop. (For loop with two variables)

Sorry for such a dreadful title, but I'm not sure how to be more descriptive. I'm hoping some of the more gurutastic out there can take a look at a solution I came up with to a problem, and advice if there are better ways to have gone about it. To make a long story short around 20K pieces of... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

10. Shell Programming and Scripting

How to run a loop for assigning strings which are present in a file to an array

Hi Forum, I am struggling with the for loop in shell script. Let me explain what is needed in the script. I have a file which will conatin some strings like file1 place1 place2 place3 checkpoint some other text some more text Now what my requirement is the words ... (2 Replies)
Discussion started by: siri_14
2 Replies
Login or Register to Ask a Question