Olivia
1
Hola,
How can I add a column to a existing file??
PS: The column which should be added need to be the first column and it will be a parameter from the script.
Example:
1 name1
2 name2
3 name3
4 name3
Need to add parameter $file as a first column. $file is a file name with time stamp which will be same for all the rows.
Thanks
Olivia
I'm not sure if that's your input data, or your output data.
We really need to see both to understand what you want.
file=<filename with timestamp>
while read LINE
do
echo "$file $LINE" >> temp_file.txt
done < input_file
temp_file.txt > input_file
As Corona688 has said, we will only get a better idea of what you want if you post more details.
This is what I roughly understood from your post.
Olivia
4
Apologize, I was not clear
That's is input
my output should be
$File 1 name1
$File 2 name2
$File 3 name3
$File 4 name4
$File is the file name generated from the script.
---------- Post updated at 04:17 PM ---------- Previous update was at 04:10 PM ----------
Thank you both yeah, thats exactly what I am looking for i appreciate your help.
---------- Post updated at 04:57 PM ---------- Previous update was at 04:17 PM ----------
Yeah it worked but is there any other way as because it's been adding first column to the blank rows too
Show us a representative sample of your input, then, and a representative sample of your output.
for your previous post ..
$ awk '{print "filename"$0}' infile
As Corona said, post sample i/p and o/p content to proceed further ..