Sponsored Content
Top Forums Shell Programming and Scripting Adding a columnfrom a specifit line number to a specific line number Post 302194090 by Ezy on Monday 12th of May 2008 08:01:51 AM
Old 05-12-2008
Java Adding a columnfrom a specifit line number to a specific line number

Hi,

I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers.

To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello" to 5th column but from line 1 to line 200. & I want to add another text "goodbye" to 5th column of the same file from line 201 to 800 & another text "live" again to 5th column to the same file from line 801 to 1000.

I know I can use sed to add a column to my file but I don't know how to tell sed to add this column to from line & to to line.


Code:
$ sed 's/\(.*\) \(.*\) \(.*\) \/\1 \2 \3 \  Desired string/' input > output

this will add my desired string to the 4th column in the right place but I don't know how to limit this to a specific range of lines.

May be there is a way to do it in sed or may be awk?

Any help will be very welcome.

Thanks in advance,
Ezy
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending line number to each line and getting total number of lines

Hello, I need help in appending the line number of each line to the file and also to get the total number of lines. Can somebody please help me. I have a file say: abc def ccc ddd ffff The output should be: Instance1=abc Instance2=def Instance3=ccc Instance4=ddd Instance5=ffff ... (2 Replies)
Discussion started by: chiru_h
2 Replies

2. Shell Programming and Scripting

how to get the data from line number 1 to line number 100 of a file

Hi Everybody, I am trying to write a script that will get some perticuler data from a file and redirect to a file. My Question is, I have a Very huge file,In that file I have my required data is started from 25th line and it will ends in 100th line. I know the line numbers, I need to get all... (9 Replies)
Discussion started by: Anji
9 Replies

3. Shell Programming and Scripting

merging line and adding number

I having file below o/p ibapp311dg,,20480,s,,,,,,,,, test,,20480,s,,,,,,,,, test,,20480,s,,,,,,,,, ibapp311dg,,20480,s,,,,,,,,, I want to to chk unique word line in the first field seperated by , as well as addup corressponding the number in field for each unique word like ibapp311dg... (8 Replies)
Discussion started by: tarunn.dubeyy
8 Replies

4. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

5. Shell Programming and Scripting

How would i delete a line at specific line number

Hi guys , I m writing a script to delete a line at particular location. But i m unable to use variable for specifying line number. for example. sed -n '7!p' filename works fine and deletes 7th line from my file but sed -n '$variable!p' filename gives following error. sed: -e... (12 Replies)
Discussion started by: pinga123
12 Replies

6. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

7. Shell Programming and Scripting

Write $line number into textfile and read from line number

Hello everyone, I don't really know anything about scripting, but I have to manage to make this script, out of necessity. #!/bin/bash while read -r line; do #I'm reading from a big wordlist instructions using $line done Is there a way to automatically write the $line number the script... (4 Replies)
Discussion started by: bobylapointe
4 Replies

8. Shell Programming and Scripting

adding line number to *end* of records in file

Given a file like this: abc def ghi I need to get to somestandardtext abc1 morestandardtext somestandardtext def2 morestandardtext somestandardtext ghi3 morestandardtext Notice that in addition to the standard text there is the line number added in as well. What I conceived is... (4 Replies)
Discussion started by: edstevens
4 Replies

9. Shell Programming and Scripting

Cut from specific line number to a line number

Hi All, I've a file like this.. Sheet1 a,1 a,2 a,3 a,4 a,5 Sheet2 a,6 a,7 a,8 a,9 a,10 Sheet3 a,11 a,12 a,13 (7 Replies)
Discussion started by: manab86
7 Replies

10. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies
ppmlabel(1)						      General Commands Manual						       ppmlabel(1)

NAME
ppmlabel - add text to a portable pixmap SYNOPSIS
ppmlabel [-angle angle] [-background transparent | colour] [-colour colour] [-file filename] [-size textsize] [-text 'text string'] [-x column] [-y row] ... [ppmfile] DESCRIPTION
ppmlabel uses the text drawing facilities of ppmdraw to add text to a portable pixmap. The location, size, baseline angle, colour of the text and background colour (if any) are controlled by command line arguments. The text can be specified on the command line or read from files. Any number of separate text strings can be added by one invocation of ppmlabel, limited only by the maximum length of the command line. If no ppmfile is specified, ppmdraw reads its input pixmap from standard input. OPTIONS
The arguments on the ppmlabel command line are not options in the strict sense; they are commands which control the placement and appear- ance of the text being added to the input pixmap. They are executed left to right, and any number of arguments may appear. All flags can be abbreviated to their shortest unique prefix. -angle angle Sets the angle of the baseline of subsequent text. angle is specified as an integral number of degrees, measured counterclock- wise from the row axis of the pixmap. -background transparent | colour If the argument is ``transparent'', text is drawn over the existing pixels in the pixmap. If a colour is given (see the -colour switch below for information on how to specify colours), rectangles enclosing subsequent text are filled with that colour. -colour colour Sets the colour for subsequent text. The colour can be specified in five ways: o A name, assuming that a pointer to an X11-style colour names file was compiled in. o An X11-style hexadecimal specifier: rgb:r/g/b, where r g and b are each 1- to 4-digit hexadecimal numbers. o An X11-style decimal specifier: rgbi:r/g/b, where r g and b are floating point numbers between 0 and 1. o For backwards compatibility, an old-X11-style hexadecimal number: #rgb, #rrggbb, #rrrgggbbb, or #rrrrggggbbbb. o For backwards compatibility, a triplet of numbers separated by commas: r,g,b, where r g and b are floating point numbers between 0 and 1. (This style was added before MIT came up with the similar rgbi style.) -file filename Reads text from the file filename and draws it on successive lines. -size textsize Sets the height of the tallest characters above the baseline to textsize pixels. -text 'text string' Draws the given text string (which must be quoted if it contains spaces). The location for subsequent text is advanced by 1.75 times the current textsize, which allows drawing multiple lines of text in a reasonable manner without specifying the position of each line. -x column Sets the column at which subsequent text will be left justified. Depending on the shape of the first character, the actual text may begin a few pixels to the right of this point. -y row Sets the row which will form the baseline of subsequent text. Characters with descenders, such as ``y'', will extend below this line. BUGS
Text strings are restricted to 7 bit ASCII. The text font used by ppmdraw doesn't include definitions for 8 bit ISO 8859/1 characters. When drawing multiple lines of text with a non-transparent background, it should probably fill the space between the lines with the back- ground colour. This is tricky to get right when the text is rotated to a non-orthogonal angle. SEE ALSO
ppmmake(1), ppm(5) AUTHOR
Copyright (C) 1995 by John Walker (kelvin@fourmilab.ch) WWW home page: http://www.fourmilab.ch/ Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided ``as is'' without express or implied warranty. 14 June 1995 ppmlabel(1)
All times are GMT -4. The time now is 12:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy