![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Appending 'string' to file as first column. | satyam_sat | Shell Programming and Scripting | 6 | 02-20-2009 05:15 AM |
| appending two string is not working | krishna9 | Shell Programming and Scripting | 11 | 05-19-2008 04:31 AM |
| Appending a string to all files in a directory | ragavhere | Shell Programming and Scripting | 1 | 04-28-2008 06:31 AM |
| appending string to text file based on search string | malaymaru | Shell Programming and Scripting | 1 | 06-09-2006 08:53 AM |
| Appending to filename a string of text grep finds | HLee1981 | Shell Programming and Scripting | 3 | 09-06-2005 02:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Sed appending string using for loop?
Hi All,
I have been trying to format a file using sed. I can't seem to get the syntax right. I want to append the string from file1.txt to file1.csv with the final output file being file2.csv, but before the string is appended to the end of each line, first insert a comma. Here is the sed command I'm running within the for loop: for i in `cat file1.txt` do sed 's/$/,'${i}'/' file1.csv > file2.csv done Below is an example of what I'm trying to accomplish: file1.txt: r2-1-config r2-2-config r2-3-config r2-4-config r2-5-config r2-6-config r2-7-config r2-8-config r2-9-config r2-10-config r2-11-config r2-12-config r2-13-config r2-14-config r2-15-config r2-16-config r2-17-config r2-18-config r2-19-config r2-20-config r2-21-config r2-22-config r2-23-config r2-24-config r2-25-config r2-26-config r2-27-config r2-28-config r2-29-config r2-30-config file1.csv: r2-1,r2-ts,2033 r2-2,r2-ts,2034 r2-3,r2-ts,2035 r2-4,r2-ts,2036 r2-5,r2-ts,2037 r2-6,r2-ts,2038 r2-7,r2-ts,2039 r2-8,r2-ts,2040 r2-9,r2-ts,2041 r2-10,r2-ts,2042 r2-11,r2-ts,2043 r2-12,r2-ts,2044 r2-13,r2-ts,2045 r2-14,r2-ts,2046 r2-15,r2-ts,2047 r2-16,r2-ts,2048 r2-17,r2-ts,2049 r2-18,r2-ts,2050 r2-19,r2-ts,2051 r2-20,r2-ts,2052 r2-21,r2-ts,2053 r2-22,r2-ts,2054 r2-23,r2-ts,2055 r2-24,r2-ts,2056 r2-25,r2-ts,2057 r2-26,r2-ts,2058 r2-27,r2-ts,2059 r2-28,r2-ts,2060 r2-29,r2-ts,2061 r2-30,r2-ts,2062 file2.csv: r2-1,r2-ts,2033,r2-1-config r2-2,r2-ts,2034,r2-2-config r2-3,r2-ts,2035,r2-3-config r2-4,r2-ts,2036,r2-4-config r2-5,r2-ts,2037,r2-5-config r2-6,r2-ts,2038,r2-6-config r2-7,r2-ts,2039,r2-7-config r2-8,r2-ts,2040.r2-8-config r2-9,r2-ts,2041,r2-9-config r2-10,r2-ts,2042,r2-10-config r2-11,r2-ts,2043,r2-11-config r2-12,r2-ts,2044,r2-12-config r2-13,r2-ts,2045,r2-13-config r2-14,r2-ts,2046,r2-14-config r2-15,r2-ts,2047,r2-15-config r2-16,r2-ts,2048,r2-16-config r2-17,r2-ts,2049,r2-17-config r2-18,r2-ts,2050,r2-18-config r2-19,r2-ts,2051,r2-19-config r2-20,r2-ts,2052,r2-20-config r2-21,r2-ts,2053,r2-21-config r2-22,r2-ts,2054,r2-22-config r2-23,r2-ts,2055,r2-23-config r2-24,r2-ts,2056,r2-24-config r2-25,r2-ts,2057,r2-25-config r2-26,r2-ts,2058,r2-26-config r2-27,r2-ts,2059,r2-27-config r2-28,r2-ts,2060,r2-28-config r2-29,r2-ts,2061,r2-29-config r2-30,r2-ts,2062,r2-30-config Last edited by cstovall; 01-28-2007 at 07:22 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|