I'm assuming I can put this line in a script so it might look like:
#!/bin/sh
# read files
cat ${WORKFILE} | while read file
do
sed 's/}/}Model_Type={t}, ModelName={m}/1' $file
done
NOTE: ${WORKFILE} is a text file that has the listing of all the files I want to edit.
---------- Post updated at 02:46 PM ---------- Previous update was at 02:32 PM ----------
After running the above script it is placing "ModelType={t}, ModelName={m}" after EVERY right curly bracket in the file. There are multiple variables in each file, which look like this: {v}. So I am getting multiple incertions in each file.
---------- Post updated at 02:52 PM ---------- Previous update was at 02:46 PM ----------
Quote:
Originally Posted by pamu
Try this..
After putting this in a loop I can see it do two things. 1st: I am getting output to the screen, but it is not writting the addition to the file
2nd: The code is adding multiple instances of "Model_Type={t}..." for each file may contain multple instances of variables, which look like: {v} where "v" is the variable letter., so, In the screen output it is adding "Model_Type=..." every time it sees another right curley bracket.
My entire script looks like this: Screen Output:
d "%w- %d %m-, %Y - %T"}Model_Type={t}, ModelName={m} - A "caSwitchLinkUpTrap" event has occurred, from {t} device, named {m}.
caSwitchLinkUp trap signifies that the caSwitchIfOperStatus object for a switch interface left the down state and transitioned into
te). This other state is indicated by the included value of caSwitchIfOperStatus.
aSwitchIfSwitchIndex = {I 1}Model_Type={t}, ModelName={m}
aSwitchIfIndex = {I 3}Model_Type={t}, ModelName={m}
aSwitchIfAdminStatus = {T caSwitchIfAdminStatus 4}Model_Type={t}, ModelName={m}
aSwitchIfOperStatus = {T caSwitchIfOperStatus 5}Model_Type={t}, ModelName={m}
event [{e}Model_Type={t}, ModelName={m}])
As can be seen, when the script is run it is looking for the right curley bracket in EACH LINE of the file. Is there a way to have the sed operation look at the FIRST LINE ONLY?
Moderator's Comments:
Please view this code tag video for how to use code tags when posting code and data.
Last edited by vbe; 09-22-2012 at 06:25 PM..
Reason: Adding information.
hi,
could anyone tell me the command to append spaces at the end of the line.
for example, i need 1000 spaces after the word "helloworld"
echo "helloworld " i need to achieve this in someother way hardcoding 1000 spaces is not practical.
as i am totally new... (3 Replies)
Hi,
I have 1 million records and want to extract lines betwen 10000 -20000 and put it in another file.
Could you please suggest a command for this.
Thanks in advance (3 Replies)
Hi Unix experts;
I have 30000 files in a directory and am willing to do the following changes on each of them. The input files look like the following:
1 , 2
3 , 4
5 , 6
7 , 8
9 , 10
the output will have # in top 10 lines, insert space instead of comma. This looks like:
... (4 Replies)
I have large file with around 100k+ lines. I wanted to retain only the last 100 lines in that file. One way i thought was using
tail -1000 filename > filename1
mv filename1 filename
But there should be a better solution.. Is there a way I can use sed or any such command to change the... (9 Replies)
Hi all,
using VI, can anyone tell me how to add some characters onto the end of a line where the line begins with certain charactars eg
a,b,c,.......,
r,s,t,........,
a,b,c,.......,
all lines in the above example starting with a,b,c, I want to add an x at the end of the line so the... (6 Replies)
Hi,
I wanted to check whether the x,y,z coordinates of two files are equal or not. At times, when one file is converted to another suitable file extension , there are some chances that the data mismatch would happen during the conversion. In order to avoid the data misfit, i would like to... (6 Replies)
I have two files (csv and vcf) which look exactly like this
S1.csv
func,gene,start,info
"exonic","AL","2309","het"
"exonic","NEF","6912","hom"S1.vcf
##fileinfo
#CHROM POS ID INFO
chr1 4567 rs323211 1/1:84,104,99
chr4 2309 rs346742 1/1:27,213,90
chr6 5834 ... (5 Replies)
Hi all,
I have 20 files (file001.txt upto file020.txt) and I want to read them from 3rd line upto end of file (line 1002). But in the final file they should appear to start from line 1.
I need following kind of output in a single file:
Filename Line number 2ndcolumn 4thcolumn
I... (14 Replies)
hi,
i need a help in the script , need to append a string at the end of each line of a files , and append the files into a single file vertically.
eg
file1 has the following columns
abc,def,aaa
aaa,aa,aaa
files 2 has the following rows and columns
abc,def,aaa
aaa,aa,aaa
i... (3 Replies)
Hi, I try to explain my problem , I have a file like this:
aasdsaffsc23
scdsfsddvf46567
mionome0001.pdb
asdsdvcxvds
dsfdvcvc2324w
What I need to do is to create 1000 files in which myname line listing a sequence of numbers from 0001 to 1000. So I want to have :
nomefile0001.txt that must... (10 Replies)