get file content and produce command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get file content and produce command
# 1  
Old 01-06-2011
Data get file content and produce command

hi buddies;

ip.txt:
Code:
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
...

parameters.txt:
Code:
portvalue
username
password
session
...

i want to produce:
Code:
l ./shell 192.168.1.1 'lt all;l+;get . portvalue;get . username;get . password;get . session;get . remaining-parameters;l-'
l ./shell 192.168.1.2 'lt all;l+;get . portvalue;get . username;get . password;get . session;get . remaining-parameters;l-'
l ./shell 192.168.1.3 'lt all;l+;get . portvalue;get . username;get . password;get . session;get . remaining-parameters;l-'
l ./shell ...same-for-remaining-IPs

any help? thx

Last edited by gc_sw; 01-06-2011 at 06:08 AM..
# 2  
Old 01-06-2011
Code:
awk 'NR==FNR{a=a?a"get . "$0";":"get . "$0";";next;}{print "i ./shell "$0" "c a "l-"c}' c="'" Code ip.txt

This User Gave Thanks to anurag.singh For This Post:
# 3  
Old 01-06-2011
thanks anurag;
this is the solution (a bit modified from yours):
Code:
awk 'NR==FNR{a=a?a"get . "$0";":"get . "$0";";next;}{print "l ./shell "$0" "c"lt all;l+;" a "l-"c}' c="'" parameters.txt ip.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sed, awk or another bash command to modify string with the content of another file

Hello everybody, I would like modify some strings using sed or another command line with the content file. For example: - {fqdn: "server-01" , ip: "server-01"} - {fqdn: "server-02" , ip: "server-02"} - {fqdn: "server-03" , ip: "server-03"} - {fqdn: "server-04" , ip: "server-04"} My... (4 Replies)
Discussion started by: dco
4 Replies

2. Shell Programming and Scripting

Split a content in a file with specific interval base on the delimited values using UNIX command

Hi All, we have a requirement to split a content in a text file every 5 rows and write in a new file . conditions: if 5th line falls between center of the statement . it should look upto after ";" files are below format: 1 UPDATE TABLE TEST1 SET VALUE ='AFDASDFAS' 2 WHERE... (3 Replies)
Discussion started by: KK230689
3 Replies

3. Shell Programming and Scripting

awk command to get file content until 2 occurrence of pattern match

AWK command to get file content until 3 occurrence of pattern match, INPUT FILE: JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <custOptIn xmlns="http://com/walm/ta/cu/ccs/xml2"> <person>Romi</person> <appName>SAP</appName> </custOptIn> ... (4 Replies)
Discussion started by: prince1987
4 Replies

4. Shell Programming and Scripting

Need help fix my script to get alerts when the command produce n expected output

Hi, Below is my script, which is used to invoke a test using curl command. #/usr/bin/sh MAILTO=user@xyz.com URL='https://myserver.xyz.net/test/dir/test123.tws' SOAPFILE=/tmp/soap.txt curl -k -s -S --header 'Content-Type: text/xml;charset=UTF-8' --data @"${SOAPFILE}" "${URL}" ... (3 Replies)
Discussion started by: System Admin 77
3 Replies

5. Red Hat

how to produce date command o/p

Hello I am trying of a solution to produce date cmnd o/p as: Feb 18 is the 049 day of the year. Any ideas how to produce this? (2 Replies)
Discussion started by: ranumala
2 Replies

6. AIX

Unable to get the full content into a file when I redirect installp command output..

When i use the command to check the preview of the filesets to be installed using CLI # When using this commad 'm able to see all Preview view of the filesets to be installed installp -apgX -d "." all # When I redirected the same output to a file 'm able to see only half the details... (1 Reply)
Discussion started by: Sounddappan
1 Replies

7. Shell Programming and Scripting

Perl Script to produce a file

hi i got a file called essay which contain few pages with many paragraphs. now i wanna with PERL to produce another file which called Essaylist that contain a sorted list of words that appear in the file essay. the format for Essaylist: $word found $times times on page a b c.... where $word... (3 Replies)
Discussion started by: mingming88
3 Replies

8. Shell Programming and Scripting

How to produce a file by many files?

i got these files: files: Prac1, Prac2, Prac3 (these 3 files have the same format), the format : Prac1 20693680 10 20179687 9 20781637 5 21907894 6 Prac2 20693680 8 20179687 6 21907894 2 Prac3 20693680 8 21907894 9 file STUDENTS, the format: 20693680:familyname, firstname (10 Replies)
Discussion started by: mingming88
10 Replies

9. Shell Programming and Scripting

Adding things in a file and produce a new one

I wanna add a ":" at the end of each line, and i did something like this: cat Totals | while read ID TOTAL do echo "${ID}:${TOTAL}:" >>Totals2 done File: Totals 12345678:13 21443433:20 The outputs file Totals2 is: 12345678:13:: 21443433:20:: but i want 12345678:13:... (3 Replies)
Discussion started by: mingming88
3 Replies

10. UNIX for Dummies Questions & Answers

Deleting all content in a file from command line

Hey guys, I'd like to delete all text within a text file without actually deleting the file. Is there a vi command I can do from my prompt without actually going into the file and doing a %d i think it is... to remove all the text inside? I want to add this to a cron job to erase all the data... (2 Replies)
Discussion started by: kingdbag
2 Replies
Login or Register to Ask a Question