Sponsored Content
Full Discussion: sed help,,kind of urgent!!
Special Forums UNIX and Linux Applications Infrastructure Monitoring sed help,,kind of urgent!! Post 302296095 by ShawnMilo on Tuesday 10th of March 2009 10:51:02 AM
Old 03-10-2009
Your description is a little confusing. Do you need to alter the second word, the second line, or the second word on the second line?

In any case, you can do this very simply with a Perl one-liner using the $. variable (which is the current line number) and a regular expression. Please post sample input and sample output from that input if you'd like me to give you the one-liner. That is, if you're open to a Perl solution.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

urgent sed help

Hi folks. I've tried to research this, but haven't found a good answer (could be my harried state). At any rate, I have records that end with two commas, a number, two commas this could be anywhere from ,,01,, to ,,09875953,, I need to remove the last two fields (the number... (3 Replies)
Discussion started by: kristy
3 Replies

2. Shell Programming and Scripting

Need urgent sed help

I am writing a shell script on SunOS cosuaah01 5.9 Generic_118558-11 sun4u sparc SUNW,Sun-Fire-V440 machine. The shell script in.sh looks like this: install_top=`pwd` fl2=/d01/applptch/ptchora/iAS/Apache/Apache/cgi-bin/cxtool/display_report.pl echo $fl2 mv $fl2 $fl2.old sed 5c\... (6 Replies)
Discussion started by: bhatia333
6 Replies

3. Shell Programming and Scripting

sed script help urgent

Collegues I am dealing with raw text files which is extracted from web pages. I have to find sentances which contains more than 99 words and have to put a "." after the 99th or 98 th word . Is there any possiblity to it in sed or awk With regards Jaganadh.H (5 Replies)
Discussion started by: jaganadh
5 Replies

4. Shell Programming and Scripting

Urgent Help With Sed

Hello, I need to use sed to replace a word in file. My command is this: sed "s/word_to_replace/'"${INPUT}"'/1 filename and because INPUT="~@#$%^&*()-_=+{}\|;:<>,./?" and / is also the delimiter so I'm keep on getting error message sed: command garbled: ... any suggestions about how I... (10 Replies)
Discussion started by: katrvu
10 Replies

5. Shell Programming and Scripting

Need Help using sed command(very urgent)

Hi all, Actually i want to delete the .ps extension from package1.ps string by using sed. Can any body tell me that how shell i do it????????? It is very urgent. Can anybody help me. I am trying to do this in the following way. ps_file="package1.ps" echo $ps_file sed s/.ps//g $ps_file... (9 Replies)
Discussion started by: sunitachoudhury
9 Replies

6. Shell Programming and Scripting

Urgent solution for simple sed

Hi Im running this command on AIX in ksh. My input file samp1 contains 1 2 123 12345 When I execute the following sed i dont get a matching pattern sed -n '/{1}/p' samp1 Can anyone help me with this simple thing (3 Replies)
Discussion started by: raghav288
3 Replies

7. Shell Programming and Scripting

awk or sed help urgent

Hello, I have a file with the follwoing pattern: Input file: =========== tcp://xxx:123 8179 YY 1798 YY tcp://abc:2345 not found tcp://swt:4945 7356 QQ tcp://pqr:456 8178 PP 9485 PP 4485 PP (8 Replies)
Discussion started by: uandme2k2
8 Replies

8. Shell Programming and Scripting

Urgent help req with grep + sed

HI all, i have a line in a file it cantains one;two_1_10;two_2_10;two_3_10;three~ now i need to get the output as one;two_1_abc_10;two_2_abc_10;two_3_abc_10;three~ ( 1 should be replaced with 1_abc for two__10 , and one more thing the number of occurances of two_value_10 will be... (1 Reply)
Discussion started by: 2001.arun
1 Replies

9. Shell Programming and Scripting

Need Urgent help on awk/sed

Hi, Sample Input Table 1 XXXXX YYYYY A 1 2 3 4 5 B 1 2 3 4 5 C 1 2 3 4 5 D 1 2 3 4 5 A 6 7 B 6 7 C 6 7 D 6 7 Table 2 XXXXX YYYYY E 1 2 3 4 5 F 1 2 3 4 5 E 6 7 F 6 7 Table 3 XXXXX YYYYY G 1 2 3 4 5 (4 Replies)
Discussion started by: ravin
4 Replies

10. Shell Programming and Scripting

sed command error-URGENT

sort.sh ------ ls -lSr|cat -n/*gives the detailed description o files with a serial number concatenated*/ i=0 n=10 j=$n if then while do (sh -C sub.sh $i $j)& ((i++)) ((j--)) done fi if then while do (sh -C sub.sh $i $j)& (1 Reply)
Discussion started by: dishak
1 Replies
grep(1) 						      General Commands Manual							   grep(1)

Name
       grep, egrep, fgrep - search file for regular expression

Syntax
       grep [option...] expression [file...]

       egrep [option...] [expression] [file...]

       fgrep [option...] [strings] [file]

Description
       Commands  of  the family search the input files (standard input default) for lines matching a pattern.  Normally, each line found is copied
       to the standard output.

       The command patterns are limited regular expressions in the style of which uses a compact nondeterministic algorithm.  The command patterns
       are  full  regular  expressions.  The command uses a fast deterministic algorithm that sometimes needs exponential space.  The command pat-
       terns are fixed strings.  The command is fast and compact.

       In all cases the file name is shown if there is more than one input file.  Take care when using the characters $ * [ ^ | ( ) and   in  the
       expression because they are also meaningful to the Shell.  It is safest to enclose the entire expression argument in single quotes ' '.

       The command searches for lines that contain one of the (new line-separated) strings.

       The command accepts extended regular expressions.  In the following description `character' excludes new line:

	      A  followed by a single character other than new line matches that character.

	      The character ^ matches the beginning of a line.

	      The character $ matches the end of a line.

	      A .  (dot) matches any character.

	      A single character not otherwise endowed with special meaning matches that character.

	      A  string  enclosed in brackets [] matches any single character from the string.	Ranges of ASCII character codes may be abbreviated
	      as in `a-z0-9'.  A ] may occur only as the first character of the string.  A literal - must be placed where it can't be mistaken	as
	      a range indicator.

	      A  regular  expression  followed	by  an	* (asterisk) matches a sequence of 0 or more matches of the regular expression.  A regular
	      expression followed by a + (plus) matches a sequence of 1 or more matches of the regular expression.  A regular expression  followed
	      by a ? (question mark) matches a sequence of 0 or 1 matches of the regular expression.

	      Two regular expressions concatenated match a match of the first followed by a match of the second.

	      Two regular expressions separated by | or new line match either a match for the first or a match for the second.

	      A regular expression enclosed in parentheses matches a match for the regular expression.

       The  order  of  precedence  of  operators at the same parenthesis level is the following:  [], then *+?, then concatenation, then | and new
       line.

Options
       -b	   Precedes each output line with its block number.  This is sometimes useful in locating disk block numbers by context.

       -c	   Produces count of matching lines only.

       -e expression
		   Uses next argument as expression that begins with a minus (-).

       -f file	   Takes regular expression (egrep) or string list (fgrep) from file.

       -i	   Considers upper and lowercase letter identical in making comparisons and only).

       -l	   Lists files with matching lines only once, separated by a new line.

       -n	   Precedes each matching line with its line number.

       -s	   Silent mode and nothing is printed (except error messages).	This is useful for checking the error status (see DIAGNOSTICS).

       -v	   Displays all lines that do not match specified expression.

       -w	   Searches for an expression as for a word (as if surrounded by `<' and `>').  For further information, see only.

       -x	   Prints exact lines matched in their entirety only).

Restrictions
       Lines are limited to 256 characters; longer lines are truncated.

Diagnostics
       Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files.

See Also
       ex(1), sed(1), sh(1)

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