zulabc
1
how to use sed to put .txt end of line..my input file below
file1
make=^bak12^".
DEV=LONG^cmd/usr/bak/ade4^"
.....................................
file 2
make=^and_LONG/bak12^".
DEV=LONG^cmd/usr/bak/ban3^"
..........................................
file 3
....................................
DEV=LONG^cmd/usr/bak/13_2^"
...............................
file 4
...............................
DEV=LONG^cmd/usr/bak/14_2^"
..........................
i want my output file become
file 1
...........
DEV=LONG^cmd/usr/bak/ade4.txt^"
......................
file 2
.................................
DEV=LONG^cmd/usr/bak/ban3.txt^"
..................................
and so on
thanks
echo 'DEV=LONG^cmd/usr/bak/ade4^"' | sed 's#..$#.txt&#'
birei
3
Hi zulabc,
Another way:
$ cat infile
DEV=LONG^cmd/usr/bak/ade4^"
DEV=LONG^cmd/usr/bak/ban3^"
DEV=LONG^cmd/usr/bak/13_2^"
DEV=LONG^cmd/usr/bak/14_2^"
$ sed 's/\(\^\)/.txt\1/2' infile
DEV=LONG^cmd/usr/bak/ade4.txt^"
DEV=LONG^cmd/usr/bak/ban3.txt^"
DEV=LONG^cmd/usr/bak/13_2.txt^"
DEV=LONG^cmd/usr/bak/14_2.txt^"
Regards,
Birei
Hi,
echo 'DEV=LONG^cmd/usr/bak/ade4^"' | sed 's#..$#.txt&#'
I would like to know how this sed command will work?
take the last 2 characters and prepend them with ".txt".
zulabc
6
my fault actually my input file is in different file
file 1
.........
DEV=LONG^cmd/usr/bak/ade4^"
................
file 2
...................
DEV=LONG^cmd/usr/bak/ban3^"
......................
and so on
so i want my output file ending with .txt before ^"
doesn't the proposed solution work?