|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Add column to a file
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 |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
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. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Code:
file=<filename with timestamp>
while read LINE
do
echo "$file $LINE" >> temp_file.txt
done < input_file
temp_file.txt > input_fileQuote:
This is what I roughly understood from your post. |
|
#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.Quote:
Yeah it worked but is there any other way as because it's been adding first column to the blank rows too ![]() |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Show us a representative sample of your input, then, and a representative sample of your output.
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
for your previous post .. Code:
$ awk '{print "filename"$0}' infileAs Corona said, post sample i/p and o/p content to proceed further .. |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
Hi.
Quote:
|
| The Following User Says Thank You to drl For This Useful Post: | ||
Franklin52 (10-06-2011) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comparing column of two different files and print the column from in order of 2nd file | CAch | Shell Programming and Scripting | 14 | 08-24-2011 01:45 PM |
| Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 | rydz00 | Shell Programming and Scripting | 7 | 11-09-2010 10:28 AM |
| creating a file using the fist column and printing second column | viralnerd | UNIX for Dummies Questions & Answers | 5 | 12-16-2009 11:05 PM |
| Changing one column of delimited file column to fixed width column | manneni prakash | Shell Programming and Scripting | 5 | 06-22-2009 05:27 AM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 09:57 AM |
|
|