Hello
How can I add a string (always the same) at the end of a specific line in a file...
The file is:
Code:
000000001 041 L $$aspa
000000001 088 L $$aJ.E.N. 551
000000001 090 L $$aINFORMES JEN
000000001 100 L $$aautor 1
----
000000002 041 L $$aeng
000000002 088 L $$aJ.E.N. 1
000000002 090 L $$aINFORMES
000000002 100 L $$aautor2
Then I would like to add this $$cData at the end of the autor line for each records
Like this:
# sed '/aautor/s/\(.*\)/\1$$cData/' infile
000000001 041 L $$aspa
000000001 088 L $$aJ.E.N. 551
000000001 090 L $$aINFORMES JEN
000000001 100 L $$aautor 1$$cData
----
000000002 041 L $$aeng
000000002 088 L $$aJ.E.N. 1
000000002 090 L $$aINFORMES
000000002 100 L $$aautor2$$cData
or awk:
Code:
# awk '/autor/{print $0"$$cData"}!/autor/{print}' infile
000000001 041 L $$aspa
000000001 088 L $$aJ.E.N. 551
000000001 090 L $$aINFORMES JEN
000000001 100 L $$aautor 1$$cData
----
000000002 041 L $$aeng
000000002 088 L $$aJ.E.N. 1
000000002 090 L $$aINFORMES
000000002 100 L $$aautor2$$cData
look if I apply this command I have a file with this:
000000119 100 L $$aRUIZ SAENZ DE MIERA, A.$$cData
000000120 100 L $$aKIM, D.$$cData
000000121 100 L $$aMIKKELSEN, D.R.$$cData
So only field 100...But all the other fields have disapear.
Look a template of the original file:
Code:
000000001 LDR L ^^^^^nam^^2200325Iia^45e0
000000001 022 L $$a0081-3397
000000001 041 L $$aspa
000000001 088 L $$aJ.E.N. 551
000000001 090 L $$aINFORMES JEN
000000001 100 L $$aROMERO, L.
000000001 245 L $$aCODIGO "REX" PARA AJUSTE DE DATOS EXPERIMENTALES A FUNCIONES EXPONENCIALES Y SU REPRESENTACION GRAFICA
000000001 250 L $$a1 ED
000000001 260 L $$aMADRID:$$b JUNTA DE ENERGIA NUCLEAR,$$c1983
000000001 300 L $$a58 P. + 5 REFERENCIAS BIBLIOGR., 1 H. DE FICHAS CON REFERENCIA BIBLIOGRAFICA Y RESUMEN DEL INFORME
000000001 340 L $$aPAPEL
....
That I want is this:
Code:
000000001 LDR L ^^^^^nam^^2200325Iia^45e0
000000001 022 L $$a0081-3397
000000001 041 L $$aspa
000000001 088 L $$aJ.E.N. 551
000000001 090 L $$aINFORMES JEN
000000001 100 L $$aROMERO, L.$$cData
000000001 245 L $$aCODIGO "REX" PARA AJUSTE DE DATOS EXPERIMENTALES A FUNCIONES EXPONENCIALES Y SU REPRESENTACION GRAFICA
000000001 250 L $$a1 ED
000000001 260 L $$aMADRID:$$b JUNTA DE ENERGIA NUCLEAR,$$c1983
000000001 300 L $$a58 P. + 5 REFERENCIAS BIBLIOGR., 1 H. DE FICHAS CON REFERENCIA BIBLIOGRAFICA Y RESUMEN DEL INFORME
000000001 340 L $$aPAPEL
My file (the output of an experiment) starts off looking like this,
_____________________________________________________________
Subjects incorporated to date: 001
Data file started on machine PKSHS260-05CP
**********************************************************************
Subject 1,... (9 Replies)
I'm trying to fully escape/quote a directory path for use in a regular expression with no characters interpreted symbolically. Printable characters get \* and white space gets "*"
$ inputDirectory="/home/dir1/dir/"
$ echo $( { while read -r -n1 a; do ] ]] && echo -n "\"""$a""\"" || echo -n... (7 Replies)
Hi,
I have a file which is an extract of jil codes of all autosys jobs in our server.
Sample jil code:
**************************
permission:gx,wx
date_conditions:yes
days_of_week:all
start_times:"05:00"
condition: notrunning(appDev#box#ProductLoad)... (1 Reply)
Platform: Solaris 10
I have a file like below
$ cat languages.txt
Spanish
Norwegian
English
Persian
German
Portugese
Chinese
Korean
Hindi
Malayalam
Bengali
Italian
Greek
Arabic
I want to append the string " is a great language" at end of each line in this file. (3 Replies)
Dear All
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB... (5 Replies)
I've a problem to put .h end of the line..below my input file
fg_a
bb
fg_b
bb
fg_c
bb
fg_d
aa
fg_f
ee
and i want the output file as below
fg_a.h
bb
fg_b.h
bb
fg_c.h
bb
fg_d.h (6 Replies)
I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed).
AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC
MY * A02 RESALE 6990788000 Y... (3 Replies)
Hi Friends, I have a file with many lines as shown below.
/START SAMPLE LINE/
M:\mmarimut_v6.4.0_pit_01\java\build.xml@@\main\v6.4.0_pit_a
M:\mmarimut_v6.4.0_pit_01\port\Post.java@@\main\v6.4.0_pit_a
M:\mmarimut_v6.4.0_pit_01\switchview\View.java@@\main\v6.4.0_pit_a
/END SAMPLE LINE/
I... (1 Reply)
HI,
I want to cut end string from line.
e.g. i have following input line
/users/home/test.txt
I want to get end string 'test.txt' from above line and length of that end string will change and it always start after '/'.
Thanks,
Visu (7 Replies)