12-04-2014
Thanks guys for your prompt response. I really appreciate it. I forgot to mention on my first post that value of host.txt is just an example. It could be different ip addresses depending on what kind of ip addresses requested by user. Let me provide another set of ip addresses.
host.txt
Quote:
10.5.3.8
172.16.3.210
192.168.0.150
192.168.7.4
output-1.txt
Quote:
host10.5.3.8 10.5.3.8
host172.16.3.210 172.16.3.210
host192.168.0.150 192.168.0.150
host192.168.7.4 192.168.7.4
output-final.txt
Quote:
create host_plain host10.5.3.8
modify network_objects host10.5.3.8 ipaddr 10.5.3.8
update network_objects host10.5.3.8
create host_plain host172.16.3.210
modify network_objects host172.16.3.210 ipaddr 172.16.3.210
update network_objects host172.16.3.210
create host_plain host192.168.0.150
modify network_objects host192.168.0.150 ipaddr 192.168.0.150
update network_objects host192.168.0.150
create host_plain host192.168.7.4
modify network_objects host192.168.7.4 ipaddr 192.168.7.4
update network_objects host192.168.7.4
Quote:
me@box:~/dbedit$ cat host.txt
10.5.3.8
172.16.3.210
192.168.0.150
192.168.7.4
me@box:~/dbedit$
me@box:~/dbedit$./script-1
me@box:~/dbedit$
me@box:~/dbedit$ cat output-1.txt
host10.5.3.8 10.5.3.8
host172.16.3.210 172.16.3.210
host192.168.0.150 192.168.0.150
host192.168.7.4 192.168.7.4
me@box:~/dbedit$
me@box:~/dbedit$./script-2
me@box:~/dbedit$
me@box:~/dbedit$ cat output-final.txt
create host_plain host10.5.3.8
modify network_objects host10.5.3.8 ipaddr 10.5.3.8
update network_objects host10.5.3.8
create host_plain host172.16.3.210
modify network_objects host172.16.3.210 ipaddr 172.16.3.210
update network_objects host172.16.3.210
create host_plain host192.168.0.150
modify network_objects host192.168.0.150 ipaddr 192.168.0.150
update network_objects host192.168.0.150
create host_plain host192.168.7.4
modify network_objects host192.168.7.4 ipaddr 192.168.7.4
update network_objects host192.168.7.4
me@box:~/dbedit$
Instead of having 2 different scripts to get the final output, is it possible to combine them so that I can run a single script to produce the final output from the initial input?
Last edited by type8code0; 12-04-2014 at 10:26 AM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
i have 2 file
1.txt :
2.txt
then i would the result become :
can anybody help me..
regards, (1 Reply)
Discussion started by: justbow
1 Replies
2. Shell Programming and Scripting
Hi all.
I'm trying to finish a bash script with the following elements:
ARRAY="blah $ITEM blah blah"
ARRAY="blah blah $ITEM blah bluh"
#ARRAY="...."
# ...the ARRAY elements represent a variable but defined
# syntax and they're all hard-coded in the script.
#(...)
ITEMS='1.0 2.3... (2 Replies)
Discussion started by: yomaya
2 Replies
3. UNIX for Dummies Questions & Answers
I need to combine two files based on the content in first column and combine it into one file . For example :
file1:
A 10
B 20
C 30
D 40
File2:
B 200
E 500
A 100
D 400
Need the output in this format:
file 3 :
column 1 Column 2 Column 3
A 10 100
B 20 ... (4 Replies)
Discussion started by: tsm2011
4 Replies
4. Shell Programming and Scripting
Hi
please help me to combine below two files into one file
file1
10.238.54.1 enk-ras-bng-cse-01 10.10.10.10
10.238.56.225 ngp-ras-bng-cto-01 10.10.10.10
file2
10.238.54.1 enk-ras-bng-cse-01 20.20.20.20
10.238.56.225 ngp-ras-bng-cto-01 20.20.20.20
Required output file
... (5 Replies)
Discussion started by: surender reddy
5 Replies
5. Shell Programming and Scripting
Dear friends,
I am just trying write one script using 2 files
one file will contain details like below
#X SERVER X LOCATION
URL="http://www.abcd.com"
FILENAME="abc.txt"
ID_NAME="myabc_xyz"
SERVER_PATH="/usr/local/dummy/html/....."
#Y SERVER Y LOCATION
URL="http://www.xyz.com"... (10 Replies)
Discussion started by: Akshay Hegde
10 Replies
6. Shell Programming and Scripting
Hi all,
I have large files with url-s ending on "|<number>" which is the Page Rank for the website as shown in the example below
http://www.machinokairo.com/2012/05/post-39.html|2
I am using "grep" to sort out all url-s in a particular way: first, remove all ending on "|0" and write the... (9 Replies)
Discussion started by: georgi58
9 Replies
7. UNIX for Dummies Questions & Answers
Hi,
Is there anyway to combine output from the awk scripting.
file01.txt:
AUE_CHMOD
AUE_CHOWN
AUE_CHROOT
AUE_CONNECT
AUE_ACCEPT
AUE_FCHOWN
AUE_FCHMOD
AUE_SETREUID
AUE_SETREGID
AUE_FCHROOT
AUE_PFEXEC
AUE_SETUID
AUE_NICE
AUE_SETGID (9 Replies)
Discussion started by: alvinoo
9 Replies
8. Shell Programming and Scripting
Hello All , I am new to this Forum,
I am trying to write a script to combine two data files with 1 column in common and others columns are different .
File1
Apple 29
tomatao 4
grapes 25
File2
Apple fruit
tomatao veg
grapes fruit
other (3 Replies)
Discussion started by: gagan0119
3 Replies
9. Shell Programming and Scripting
Greetings,
I have large file with following format
name1 name2
name3 name4
name5 name6
child7 child8 child9 <== there is leading blank space
child10 child11 child12 <== there is leading blank space
name13 name14
name15 name16
child17 child18... (6 Replies)
Discussion started by: rnnyusa
6 Replies
10. Shell Programming and Scripting
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
Discussion started by: siegfried
3 Replies
LEARN ABOUT X11R4
libbash
LIBBASH(7) libbash Manual LIBBASH(7)
NAME
libbash -- A bash shared libraries package.
DESCRIPTION
libbash is a package that enables bash dynamic-like shared libraries. Actually its a tool for managing bash scripts whose functions you may
want to load and use in scripts of your own.
It contains a 'dynamic loader' for the shared libraries ( ldbash(1)), a configuration tool (ldbashconfig(8)), and some libraries.
Using ldbash(1) you are able to load loadable bash libraries, such as getopts(1) and hashstash(1). A bash shared library that can be loaded
using
ldbash(1) must answer 4 requirments:
1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash).
2. It must contain a line that begins with '#EXPORT='. That line will contain (after the '=') a list of functions that the library
exports. I.e. all the function that will be usable after loading that library will be listed in that line.
3. It must contain a line that begins with '#REQUIRE='. That line will contain (after the '=') a list of bash libraries that are
required for our library. I.e. every bash library that is in use in our bash library must be listed there.
4. The library must be listed (For more information, see ldbashconfig(8)).
Basic guidelines for writing library of your own:
1. Be aware, that your library will be actually sourced. So, basically, it should contain (i.e define) only functions.
2. Try to declare all variables intended for internal use as local.
3. Global variables and functions that are intended for internal use (i.e are not defined in '#EXPORT=') should begin with:
__<library_name>_
For example, internal function myfoosort of hashstash library should be named as
__hashstash_myfoosort
This helps to avoid conflicts in global name space when using libraries that come from different vendors.
4. See html manual for full version of this guide.
AUTHORS
Hai Zaar <haizaar@haizaar.com>
Gil Ran <ril@ran4.net>
SEE ALSO
ldbash(1), ldbashconfig(8), getopts(1), hashstash(1) colors(1) messages(1) urlcoding(1) locks(1)
Linux Epoch Linux