How to pass strings from a list of strings from another file and create multiple files?
Hello Everyone ,
Iam a newbie to shell programming and iam reaching out if anyone can help in this :-
I have two files
1) Insert.txt
2) partition_list.txt
insert.txt looks like this :-
partition_list.txt looks like this :-
Each string in the partition_list.txt should replace both the "partition_name" string in the insert.txt file and create a new file for each string used in the partition_list.txt . How can this be achieved without opening the files and modifying . how can it be done through sed or awk ?
For ex :- The end o/p would be 8 new files. sample file will be :-
so there should be 8 like to be generated based on each line in partition_list.txt.
Iam sorry if i havent used to code tag button ...i apologise .
Hi nubie2linux,
Welcome to the UNIX & Linux Forums.
Your use of CODE tags is fine (and appreciated).
You haven't said what operating system (although we might guess that it is some Linux distribution from your choice of user name) or shell you're using... With a POSIX conforming shell (such as ksh [which is used in the examples below] or bash) and sed utility you could use something like:
Or, more efficiently, but requiring a little more typing, with awk:
If you want to use awk on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
This User Gave Thanks to Don Cragun For This Post:
I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file.
I would like to output the lines of File2 which... (1 Reply)
I have a bunch of file numbers in the file 'test':
I'm trying the above command to change all the instances of "H" to "Na+" in the file testsds.pdb at the line numbers indicated in the file 'test'. I've tried the following and various similar alternatives but nothing is working:
cat test |... (3 Replies)
I have a list of files all over a file system e.g.
/home/1/foo/bar.x
/www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g.
if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc.
There... (2 Replies)
I have the following lines in a log file. It would be great if some one can help me to create a new file with the just entries in the below format.
66.150.161.195 HPSAC=Z05
66.150.161.196 HPSAC=A05
That is just extract the IP address and the string DPSAC=its value
66.150.161.195 -... (1 Reply)
I have a file 1.txt with the below contents.
-----cat 1.txt-----
1234
5678
1256
1234
1247
-------------------
I have 3 more files in a folder
-----ls -lrt-------
A1.txt
A2.txt
A3.txt
-------------------
The contents of those three files are similar format with different data values... (8 Replies)
The question is not as simple as the title... I have a file, it looks like this
<string name="string1">RZ-LED</string>
<string name="string2">2.0</string>
<string name="string2">Version 2.0</string>
<string name="string3">BP</string>
I would like to check for duplicate entries of... (11 Replies)
Hello Team,
There is this situation where there are around 20 *.gz files and i want to search multiple words from all those files.
Example as below :
filea.gz
fileb.gz
filec.gz
now i want to search words "hi" and "hello" from all these 3 files without... (4 Replies)
Hello guys,
should be a very easy questn for you:
I need to delete strings in file1 based on the list of strings in file2.
like file2:
word1_word2_
word3_word5_
word3_word4_
word6_word7_
file1:
word1_word2_otherwords..,word3_word5_others... (7 Replies)
Hi,
I will use below command for grep single string ("osuser" is search string)
ex: find . -type f | xarg grep -il osuser
but i have one more string "v$session"
here i want to grep in which file these two strings are present.
any help is appreciated,
Thanks in advance.
Gagan (2 Replies)
Hi guys,
say I have a few files in a directory (58 text files or somthing)
each one contains mulitple strings that I wish to replace with other strings
so in these 58 files I'm looking for say the following strings:
JAM (replace with BUTTER)
BREAD (replace with CRACKER)
SCOOP (replace... (19 Replies)