Sponsored Content
Top Forums UNIX for Dummies Questions & Answers using sed to append text to the end of each line Post 82173 by Redg on Monday 29th of August 2005 01:19:25 PM
Old 08-29-2005
using sed to append text to the end of each line

Anyone know how to use SED to append a comma to the end of each line

example:

field1,field2,field3,field4

If i Cat /textfile ---- How can i append the end of /textfile with a comman?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

2. Shell Programming and Scripting

Sed : identify a pattern and append a word at the end of a line

Hello to all, On aix, I want to identify a term on a line in a file and then add a word at the end of the line identified. I do not want the word to be added when the line contains the symbol "#". I use the following command, but it deletes the term identified then adds the word. #sed... (4 Replies)
Discussion started by: dantares
4 Replies

3. Shell Programming and Scripting

Append text to end of line on all lines

Hi, I've spent some time researching for this but can't seem to find a solution. I have a file like this 1234|Test|20101111|18:00|19:00There will be multiple lines in the file with the same kind of format. For every line I need to make it this 1234|Test|20101111|18:00|19:00||create... (5 Replies)
Discussion started by: giles.cardew
5 Replies

4. Shell Programming and Scripting

append text from file1 to the end of each line in file2

hi; my file2.txt:portname=1;list=10.11;l- portname=2;list=10.12;l- portname=3;list=10.13;l- ... my file1.txt:;"{'sector=%27'}"\&> so; i want to see:portname=1;list=10.11;l-;"{'sector=%27'}"\&> portname=2;list=10.12;l-;"{'sector=%27'}"\&> portname=3;list=10.13;l-;"{'sector=%27'}"\&>... (4 Replies)
Discussion started by: gc_sw
4 Replies

5. Shell Programming and Scripting

Append text to end of every line

I've scoured the internet with mixed results. As an amateur I turn to the great minds here. I have a text file of 80 or so lines. I want to add ".pdf" to the end of each line. (For now that's it) Most of the internet points toward using "sed". I don't know coding but can figure things out... (4 Replies)
Discussion started by: spacebase
4 Replies

6. Shell Programming and Scripting

find a certain line and append text to the end of the line

After I create printer queues in AIX, I have to append a filter file location within that printers custom file. within lets say test_queue.txt I need to find the row that starts with :699 and then I need to append on the end the string /usr/local/bin/k_portrait.sh. Now I've gotten the sed... (2 Replies)
Discussion started by: peachclift
2 Replies

7. Shell Programming and Scripting

Append text to line if begins with pattern1 AND does not end with pattern2

Hello, I'm looking for sed solution to change ... <li>keyword</li> <li>keyword <li>keyword</li> <li>keyword <li>keyword</li> ... to ... <li>keyword</li> <li>keyword</li> <li>keyword</li> <li>keyword</li> <li>keyword</li> ... I.e., if lines beginning with <li> do not end with... (3 Replies)
Discussion started by: pioavi
3 Replies

8. Shell Programming and Scripting

SED and Solaris Append line to the end of File does not work

Hello, I have to add a new line at the end of a File on Solaris-System: I think my script should be right, because I evaluated it to other threads. However the script does not what I am expected it should do. My file might look like this: Line1 Line2 Line3 And my script could... (7 Replies)
Discussion started by: Timo_HR
7 Replies

9. Shell Programming and Scripting

sed - Find a String and append a text end of the Line

Hi, I have a File, which have multiple rows. Like below 123456 Test1 FNAME JRW#$% PB MO Approver XXXXXX. YYYY 123457 Test2 FNAME JRW#$% PB MO Super XXXXXX. YYYY 123458 Test3 FNAME JRW#$% PB MO Approver XXXXXX. YYYY I want to search a line which contains PB MO Approver and append... (2 Replies)
Discussion started by: java2006
2 Replies

10. Shell Programming and Scripting

sed command to append word at end of line

hello Team, I am looking for sed command or script which will append word at end of line. for example. I want to validate particular filesystem with mount |<filesystem name> command. if nodev parameter is not there then it should add in the fstab file with receptive to the filesystem. # mount... (8 Replies)
Discussion started by: ghpradeep
8 Replies
join(1) 						      General Commands Manual							   join(1)

Name
       join - join files

Syntax
       join [ -a n] [ -e string] [ -j  n m] [ -o list] [ -t c]	file1 file2

Description
       The  command  compares a field in file1 to a field in file2.  If the two fields match, the command combines the line in file1 that contains
       the field with the line in file2 that contains the field.  The command writes its output to standard output.  If you specify a  hyphen  (-)
       in the file1 argument, compares standard input to the contents of file2.

       The command compares and combines the input files one line at a time. Each line in the input file contains one field that uses to determine
       if two lines should be joined.  This field is called the join field. By default, the command uses the first field in each line as the  join
       field.	The  command  compares	the join field in the first line of file1 to the join field in the first line of file2.  If the two fields
       match, the command joins the lines.  The command then compares the join fields in the second line of both files, and so on.

       In the input files, fields are separated by tab or space characters.  The command reads data from the first field until it encounters a tab
       or  space  character,  which  terminates the first field.   By default, the command ignores tab and space characters, so the next character
       that is not a tab or space begins the second field.  The second field is terminated by the tab or space that  follows  it,  and	the  third
       field begins with the next character that is not a tab or space.  The command reads fields in this way until it encounters a new line char-
       acter.  Any number of tabs or spaces can separate two fields, and any number of newline characters can separate two lines.

       Both file1 and file2 must be ordered in the collating sequence of the command on the fields that  the  two  files  are  to  be  joined.	By
       default, uses the first field in each line and collates the same as

       To  create  output,  the  command writes the join field, followed by the remaining fields in the line from file1, followed by the remaining
       fields in the line from file2 to the output file.  The following demonstrates how lines in the  output appear by default:
       join_field file1.field2 file1.field3 file1.field4 file2.field2 file2.field3

       By default, the command ignores lines that do not contain identical join fields.  The command writes no output for these lines.

       You can change how creates output using command options.  For example, you can cause the command to write output for lines that do not con-
       tain  identical	join  fields.	You  can  also	specify  a  list  using  the option.  In list, you supply a list of specifiers in the form
       file.field, where file is either 1 or 2 and field is the number of the field.  For example, 1.2 specifies the second  field  in	the  first
       file  and 2.4 specifies the fourth field in the second file. The following demonstrates how lines in the output appear if you use these two
       specifiers:
       file1.field2 field2.field4

   International Environment
       LC_COLLATE     If this environment variable is set and valid, uses the international language database named in the definition to determine
		      collation rules.

       LC_CTYPE       If this environment variable is set and valid, uses the international language database named in the definition to determine
		      character classification rules.

       LANG	      If this environment variable is set and valid uses the international language database named in the definition to  determine
		      collation  and character classification rules.  If LC_COLLATE or LC_CTYPE is defined their definition supercedes the defini-
		      tion of LANG.

Options
       -a[n]	   Write lines that contain unmatched join fields to the output file.  You can cause the command to  write  unmatched  lines  from
		   only  one  file  using  n.  If you specify 1 in n, writes unmatched lines only from file 1.	If you specify 2, writes unmatched
		   lines only from file 2.

		   If you omit the option, writes no output for unmatched lines.

       -e s	   Writes the string you specify in s to the output if you specify a nonexistent field in the list for the option.   For  example,
		   if lines in file 2 contain only three fields, and you specify 2.4 in list, writes s in place of the nonexistent field.

       -jn m	   Defines  field  m  in file n to be the join field. The command compares the field you specify in the option to the default join
		   field in the other file.  If you omit n, the command uses the mth field in both files.

       -1 m	   Use the m th field in the first file as the join field.  This option is equivalent to using m.

       -2 m	   Use the m field in the second file as the join field.  This option is equivalent to using m.

       -o list	   Output the joined data according to list.  The specifiers in list have the format file.field, where file is either 1 or  2  and
		   field is the number of the field.

       -tc	   Recognize the tab character c.  The presence of c in a line is significant, both for comparing join fields and creating output.

Restrictions
       If you specify the option, the command collates the same as with no options.

Examples
       Suppose that by issuing the following commands, you display the files shown in the example:
       % cat file_1
       apr     15
       aug     20
       dec     18
       feb     05
       % cat file_2
       apr     06
       aug     14
       date
       feb     15
       Both files are sorted in ascending order.

       If you issue the command without options, the output appears as follows:
       % join file_1 file_2
       apr 15 06
       aug 20 14
       feb 05 15
       The third line in each input file is not joined in the output because the join fields (date and dec) do not match.

       To  join  the  lines  in these files and format the output so that the second field from each file appears first and the first (join) field
       appears second, issue the following command:
       % join -o 1.2 1.1 2.2 2.1 file_1 file_2
       15 apr 06 apr
       20 aug 14 aug
       05 feb 15 feb
       To write lines that are unmatched to the output, issue the following command:
       % join -a file_1 file_2
       apr 15 06
       aug 20 14
       date
       dec 18
       feb 05 15

See Also
       awk(1), comm(1), sort(1), sort5(1), environ(5int)

																	   join(1)
All times are GMT -4. The time now is 12:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy