Sponsored Content
Top Forums Shell Programming and Scripting How to combine 2 texts file and create another file from it? Post 302752759 by type8code0 on Monday 7th of January 2013 01:09:01 PM
Old 01-07-2013
How to combine 2 texts file and create another file from it?

Hi all,

I've the following hostnames & ip addresses saved in host_ip.txt

Quote:
H1 1.1.1.1
H2 2.2.2.2
H3 3.3.3.3
....
H99 99.99.99.99
Based on this list, I need to create the following script.

Quote:
create host_plain HH
modify network_objects HH ipaddr XXXX
update network_objects HH
where by HH is a hostname
and XXXX is an ip address

So the final output would be something like this.

Quote:
create host_plain H1
modify network_objects H1 ipaddr 1.1.1.1
update network_objects H1

create host_plain H2
modify network_objects H2 ipaddr 2.2.2.2
update network_objects H2

create host_plain H3
modify network_objects H3 ipaddr 3.3.3.3
update network_objects H3

....

create host_plain H99
modify network_objects H99 ipaddr 9.9.9.9
update network_objects H99
Currently, I'm doing it manually, replace, copy and paste. Since there are hundreds of Hosts & IP Addresses, I really appreciate if someone could help me to automate this task using a script or any methods. Thanks in advance
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate sentences from two texts, combine them

I havet two books, one in Swedish, the other in English. Two text files. I want to combine them into one, with each sentence having it's translation next to it. ------------ Text file one. Example sentence in English. Example 2 sentence 2 in English 2. -------------- Text file two. ... (2 Replies)
Discussion started by: LaraMej
2 Replies

2. Shell Programming and Scripting

Read a file and search a value in another file create third file using AWK

Hi, I have two files with the format shown below. I need to read first field(value before comma) from file 1 and search for a record in file 2 that has the same value in the field "KEY=" and write the complete record of file 2 with corresponding field 2 of the first file in to result file. ... (11 Replies)
Discussion started by: King Kalyan
11 Replies

3. Shell Programming and Scripting

How to write a shell script to notify when certain texts appear in a file?

I have a server and occasionally the file mysqld.log would show something like /usr/libexec/mysqld: Disk is full writing './example_com_-_wordpress/wp_statpress.MYD' (Errcode: 122). Waiting for someone to free space... Retry in 60 secs How do I write a simple shell script to check mysqld.log... (1 Reply)
Discussion started by: acider
1 Replies

4. Shell Programming and Scripting

Help me to combine two file

Hi, can anybody help me. I want to combine these two file into one horizontally. 1st File: ... 10:00 10:01 10:02 10:03 10:04 10:05 ... 2nd File: ... 0715 10:00 Caps: 50 0715 10:01 Caps: 65 0715 10:02 Caps: 75 0715 10:04 Caps: 50 0715 10:05 Caps: 87 (3 Replies)
Discussion started by: lurak
3 Replies

5. Shell Programming and Scripting

Two Huge Texts and Combine Result to Third

hi, i want to examine two file and write some codes to a third file. note that seperators are TAB, not space. first file: 192.168.1.1 3 192.168.1.2 2 192.168.3.2 2 192.168.7.3 1 ... second file: 192.168.1.1 1 10.15.1.1 3 30 10.15.2.1 2 40 192.168.1.1 2 10.23.4.5... (3 Replies)
Discussion started by: gc_sw
3 Replies

6. UNIX for Dummies Questions & Answers

Searching for Multiple texts in a file

Hello guys, I hope anyone can help me with this ... I have a file in which i have around 6000 lines of same format text like 1234567 2345678 3456789 .................... Now what I have to do is that there I have to search these numbers in another file which contains hundreds of... (1 Reply)
Discussion started by: m_usmanayub
1 Replies

7. Shell Programming and Scripting

Serach a string for multiple occurrences in a file and cut related texts

Hi, I want a help in this forum for my below issue. 1. I have a file where I'm searching for a text . 2. When I get the line where the above string is present I want to cut some texts from the line where the particular string was found. These above two steps will repeat in the... (2 Replies)
Discussion started by: bhaski2012
2 Replies

8. UNIX for Dummies Questions & Answers

Need to combine two lines in a file based on first character of each line in a file

Hi, I have a requirement where I need to combine two lines in a file based on first character of each line in a file. Please find the sample content of the file below: Code: _______________________ 5, jaya, male, 4-5-90, single smart 6, prakash, male, 5-4-84, married fair 7, raghavi,... (1 Reply)
Discussion started by: jayaP
1 Replies

9. UNIX for Advanced & Expert Users

Need to combine two lines in a file based on first character of each line in a file

Hi, I have a requirement where I need to combine two lines in a file based on first character of each line in a file. Please find the sample content of the file below: Code: _______________________ 5, jaya, male, 4-5-90, single smart 6, prakash, male, 5-4-84, married fair 7, raghavi,... (1 Reply)
Discussion started by: jayaP
1 Replies
KSPLICE-APPLY(8)						      Ksplice							  KSPLICE-APPLY(8)

NAME
ksplice-apply - Apply an on-disk Ksplice update to the running kernel SYNOPSIS
ksplice-apply [OPTIONS] {UPDATE_TARBALL | UPDATE_TREE} DESCRIPTION
ksplice-apply takes as input a Ksplice update, as generated by ksplice-create(8), and it applies the update to the running binary kernel. The update may be supplied in the form of a tarball or an unpacked tree. The update is required to have been generated for the running kernel's version. OPTIONS
--debug Applies the update with debugging output enabled. Recommended only for debugging. --debugfile=filename Sets the location where debugging output should be saved. Implies --debug. --partial Applies the update only to those modules which are loaded. Any modules patched by the update that are not loaded are ignored (without this option, Ksplice aborts if any modules patched by the update are not loaded). --raw-errors Print only raw error information designed to be machine-readable on standard error (standard output is still intended to be human- readable). If ksplice-apply fails due to an error from the Ksplice kernel modules, the first line on standard error will be a Ksplice abort code (see the Ksplice source code for documentation on these codes). Further lines will vary depending on the abort code. If ksplice-apply fails for any other reason, it will output the line "OTHER ", followed by a human-readable failure message, to standard error. SEE ALSO
ksplice-create(8), ksplice-view(8), ksplice-undo(8) BUGS
Please report bugs to <devel@ksplice.com>. AUTHORS
Jeff Arnold, Anders Kaseorg, and Tim Abbott COPYRIGHT
Copyright (C) 2007-2009 Ksplice, Inc. This is free software and documentation. You can redistribute and/or modify it under the terms of the GNU General Public License, version 2. Ksplice v0.9.9 2011-02-13 KSPLICE-APPLY(8)
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy