Insert output from a file to beginning of line with sed
Hi
I've been trying to search but couldn't quite get the answer I was looking for.
I have a a file that's like this
How do I make it so the file will be like this?
I tried doing something like this and variations of this, but can't seem to get it to work.
It doesn't seem that $DATETMP is inserting into the beginning of the line.
Any help is extremely appreciated.
Thank you.
Last edited by Franklin52; 10-02-2012 at 04:02 AM..
Reason: Please use code tags for data and code samples
---------- Post updated at 11:18 AM ---------- Previous update was at 11:05 AM ----------
Actually sorry, I spoke too soon. I should have explained a little more clear
My source file is more like this
How do I make it so the file will be like this?
I tried doing something like this,
I'm getting good results with the first date (sept 1, 11), however once it's sept 2, 11, I get only a blank at the front of the line.
e.g.,
How do I get the $n variable into awk -F "," 'NR==1{x=$'$n';next} {sub("^",x",")}1' properly?
Any help is appreciated.
Thank you
---------- Post updated at 11:49 AM ---------- Previous update was at 11:18 AM ----------
Nevermind, I figured it out.
Thank you all for your help.
Last edited by Franklin52; 10-02-2012 at 04:04 AM..
Reason: Code tags
I need to manipulate one Database file on Solaris 11 in which contains more than 5000 lines of data file path like this:
'/data1/oradata/DBNAME/system01.dbf',
'/data7/oradata/DBNAME/undotbs1_01.dbf',
'/data1/oradata/DBNAME/sysaux01.dbf',
'/data28/oradata/DBNAME/userdata01.dbf',
... (6 Replies)
Hi everyone :)
I have a file "words.txt" containing hundreds of lines of text. Each line contains a slogan.
Using the code below i am able to generate an image with the slogan text from each line.
The image filename is saved matching the last word on each line.
Example:
Line 1: We do... (2 Replies)
i am trying to
insert text at the beginning of every even number line
with awk
i can do it with odd number lines
with this command
awk 'NR%2{$0="some text "$0}1' filehow can i edit this command
thanks (5 Replies)
By using sed command, How to insert a new line before the last four lines of the file.
Old Line
Old Line
NEW LINE!
Old Line
Old Line
Old Line
Old Line (8 Replies)
Hi all,
I have a file called "text.cpp" with the first line of "1"
afterwards I tried in Ubuntu to type the following
sed '12iasdasdasdasdsad' test.cpp > output.txt
however when I tried to see the result of output.txt
#cat output.txt
1
why is the line 12 is not updated to the... (6 Replies)
hi I am trying to use SED to replace the line matching a pattern using the command
sed 'pattern c\
new line
' <file1 >file 2
I got two questions
1. how do I insert a blank space at the beginning of new line?
2. how do I use this command to execute multiple command using the -e... (5 Replies)
How can I insert the command executed on the shell into the first line of my output file?
For example if I execute;
zcat *.gz |grep “User5501” > users.out
How can I make my users.out look like;
zcat *.gz |grep “User5501” > users.out
User5501 PA
User5501 UA
User5501 ZA... (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)
I need to insert the output of a script into a specific line number of a txt file.
I've read the Sed man page and searched the forums and it's not immediately clear how I would go about doing this. (4 Replies)
Hi, excuse me for my poor english.
My problem is that:
I have a File
i want to add to each line of that file two strings: one at the beginning of the line, one at the ending.
string1="abcd"
string2="efgh"
i want $string1 content $string2 for each line.
Is that possible? (3 Replies)