Hi I was wondering if anyone new of a solution to this problem? I need to copy a time stamp that is on a line of .text in a text file into multiple positions on the same line.
I need to insert the time stamp on the same line between every occurance of the text ".pdf_.html" right after the underscore and before the ".html"
I've tried using sed and the \1 function without much luck.
I would be very thankful if anyone was able to provide a solution.
Below is an example of the code I'm trying to use.
What this sed script does is find the one occurrence of the time stamp on the line and inserts
".pdf_.html" around it, which is sort of what I had intended but not quit, I actualy need the time stamp to be inserted between every occurance of ".pdf_.html" after the underscore and before the .html
any help would be much appreciated
thanks
Maybe I should expailed myself more thoroughly. What I am trying to do is pick up a string of text from the begining of the line, an example of the string is this: "05-03-2013-08-59-16", this string is actualy a time stamp, that is associated with a number of file names that appear later on in the same line. The file names all end the same way, that is with a ".pdf_.html" I need to insert the string from the beginning of the line between the ".pdf_" and the ".html" everytime there is an occurance of ".pdf_.html"
Here is an example of the original text file:
And the following is the way I need it to look:
Also string that represents the time stamp will never be constant except for the format of numbers and dashes, and I need to perform the same operation on a number of files with changing time stamps and filenames.
The only constant will be the format of the timestamp and the position of the string: ".pdf_.html" at the end of the file names
thanks very much for all your help
Hello, I am trying to insert a section of text between lines in another text file.
The new lines to be inserted are:
abcd.efgh.zzzz=blah
abcd.efgh.xxxx=blah
Where N = 0 to 2
Original File:
abcd.efgh.wwxx=aaaaa
abcd.efgh.yyzz=bbbbb
abcd.efgh.wwxx=aaaaa
abcd.efgh.yyzz=bbbbb... (3 Replies)
Hi
I am trying to insert a block of text 2 lines above a pattern match using sed
eg
#Start of file entry
{
}
#End of file entry
new bit of text has to be put in just above the } eg
#Start of file entry
{
New bit of text
}
#End of file entry (7 Replies)
I have:
/path/to/my/fixdir/MD1234567.tar
I want to have:
/path/to/my/fixdir/MD/1234567.tar
fixdir never changes but MD does and how many numerical digits does. I want something like:
/usr/bin/sed 's/fixdir\/../fixdir\/..\//'
This ends up:
/path/to/my/fixdir/../1234567.tar
But... (3 Replies)
sed '1r file.txt' <source.txt >desti.txt
This example will insert 'file.txt' between line 1 and 2 of source.txt.
sed '0r file.txt' <source.txt >desti.txt
gives an error message.
Does anyone know how 'sed' can insert 'file.txt' before the first line of source.txt? (18 Replies)
Hi,
I use sed to insert text at beginning of a file. But sed inserts a newline after my text that I do not need. For example, I want to insert "foo" at the beginning of my file:
> cat myfile
This is first line.
> sed -i '1i\foo' myfile
> cat myfile
foo
This is first line.
... (5 Replies)
Hello. I'm trying to insert text in various positions and I could only do that using pipes for each position.
Example:
cat file | sed -e 's#\(.\{5\}\)\(.*\)#\1:\2#g' | sed -e 's#\(.\{26\}\)\(.*\)#\1:\2#g'
Insert ":" at position 5 and 26.
it can be done in the same sentence, without using... (4 Replies)
Hi all,
I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output.
sed '$a\
hi...
' shell > shell1
But I face problem when using the same in script. It is throwing the error as,
sed: command garbled:... (4 Replies)
Hello. Trying to insert text at line 1 and after last line of file. I have searched posts but nothing seems to work. I keep getting extra characters error or nothing gets inserted into the file.
#!/bin/sh
touch textfile.txt
sed 'i\
Add this line before every line with WORD' textfile.txt
... (5 Replies)