Sponsored Content
Top Forums UNIX for Dummies Questions & Answers add a string to a file without line break Post 302720851 by spacebar on Wednesday 24th of October 2012 05:25:45 PM
Old 10-24-2012
See if this is what you want:
Code:
$ cat t
col1,col2,col3,col4,col5,col6,col7
a1,a2,a3,a4,a5,a6,a7
b1,b2,b3,b4,b5,b6,b7
c1,c2,c3,c4,c5,c6,c7
d1,d2,d3,d4,d5,d6,d7

** Add string ",string" to end of each line with sed
$ sed 's/$/,string/' t
col1,col2,col3,col4,col5,col6,col7,string
a1,a2,a3,a4,a5,a6,a7,string
b1,b2,b3,b4,b5,b6,b7,string
c1,c2,c3,c4,c5,c6,c7,string
d1,d2,d3,d4,d5,d6,d7,string

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to insert line break + string in vi (search & replace )

Hello all i have big test file that has allot of structure text something like this : <foo1 *.html> <blah action> somthing 1 somthing 2 </blah> </foo1 > now i will like to insert 2 more lines of text below the <blah action> so it will be like : <foo1... (1 Reply)
Discussion started by: umen
1 Replies

2. Shell Programming and Scripting

Trim whitespace and add line break

All, I'm a newbie at shell scripting and regular expressions and I just need to take a file that's arranged like the one below, remove all leading and trailing whitespace and add a line break after each word. I've been able to remove a few spaces using various awk, sed and Perl scripts, but... (7 Replies)
Discussion started by: moose1
7 Replies

3. Shell Programming and Scripting

line break if string exceeds 100chars

I am required to develop a script to look for specific strings in the /var/adm/messages file on our Solaris10 host. When an entry is found in the file then I need that line to be piped to a log file. I have a script with the criteria i just need help with the manipulation of the text string. 1.... (6 Replies)
Discussion started by: s1ckle
6 Replies

4. Shell Programming and Scripting

Add line break for each line in a file

I cannot seem to get this to work.. I have a file which has about 100 lines, and there is no end of line (line break \n) at the end of each line, and this is causing problem when i paste them into an application. the file looks like this this is a test that is a test balblblablblhblbha... (1 Reply)
Discussion started by: fedora
1 Replies

5. Shell Programming and Scripting

break the string and print it in a new line after a specific word

Hi Gurus I am new to this forum.. I am using HP Unix OS. I have one single string in input file as shown below Abc123 | cde | fgh | ghik| lmno | Abc456 |one |two |three | four | Abc789 | five | Six | seven | eight | Abc098 | ........ I want to achive the result in a output file as shown... (3 Replies)
Discussion started by: kannansr621
3 Replies

6. Shell Programming and Scripting

Add Some String on each line of file

HI Guys, I am new user its my first post. I have one file in DIR XYZ. File name is ABCDEF.log Now i want to add that file in each line of file. I have data in file ABCDEF.log TestKLFH TEstLKHU HESTLJHG Now i want to update the file with below data ABCDEFG.log:TestKLFH... (5 Replies)
Discussion started by: asavaliya
5 Replies

7. Shell Programming and Scripting

Modify a file by another file: add new line and variable after string is found

hello, I have problem with writing/adjusting a shell script. I searched forum and unfortunately couldn't write scipt based on the information I found. I never wtire such so it's hard for me and I do need to modify one script immediately. case looks like: 1. 'file' that needs to be modified... (3 Replies)
Discussion started by: bipbip
3 Replies

8. Shell Programming and Scripting

Search a string in a text file and add another string at the particular position of a line

I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies

9. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

10. Shell Programming and Scripting

Replace and add line in file with line in another file based on matching string

Hi, I want to achieve something similar to what described in another post: The difference is I want to add the line if the pattern is not found. File 1: A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB ... (11 Replies)
Discussion started by: jyu3
11 Replies
Text::FormatTable(3pm)					User Contributed Perl Documentation				    Text::FormatTable(3pm)

NAME
Text::FormatTable - Format text tables SYNOPSIS
my $table = Text::FormatTable->new('r|l'); $table->head('a', 'b'); $table->rule('='); $table->row('c', 'd'); print $table->render(20); DESCRIPTION
Text::FormatTable renders simple tables as text. You pass to the constructor (new) a table format specification similar to LaTeX (e.g. "r|l|5l|R|20L") and you call methods to fill the table data and insert rules. After the data is filled, you call the render method and the table gets formatted as text. Methods: new($format) Create a Text::FormatTable object, the format of each column is specified as a character of the $format string. The following formats are defined: l Left-justified top aligned word-wrapped text. L Left-justified bottom aligned word-wrapped text. r Right-justified top aligned word-wrapped text. R Right-justified bottom aligned word-wrapped text. 10R, 20r, 15L, 12l, Number is fixed width of the column. Justified and aligned word-wrapped text (see above). ' ' A space. | Column separator. head($col1, $col2, ...) Add a header row using $col1, $col2, etc. as cell contents. Note that, at the moment, header rows are treated like normal rows. row($col1, $col2, ...) Add a row with $col1, $col2, etc. as cell contents. rule([$char]) Add an horizontal rule. If $char is specified it will be used as character to draw the rule, otherwise '-' will be used. render([$screen_width]) Return the rendered table formatted with $screen_width or 79 if it is not specified. SEE ALSO
Text::ASCIITable COPYRIGHT
Copyright (c) 2001-2004 Swiss Federal Institute of Technology, Zurich. (c) 2009 Trey Harris All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. CODE REPOSITORY
Git - http://github.com/treyharris/Text-FormatTable/tree/master AUTHOR
David Schweikert <dws@ee.ethz.ch> Maintained by Trey Harris <treyharris@gmail.com> Fixed column width and bottom alignment written by Veselin Slavov <vslavov@creditreform.bg> perl v5.10.0 2009-07-24 Text::FormatTable(3pm)
All times are GMT -4. The time now is 01:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy