Sponsored Content
Full Discussion: Urgent Help With Sed
Top Forums Shell Programming and Scripting Urgent Help With Sed Post 302165436 by katrvu on Thursday 7th of February 2008 10:43:45 PM
Old 02-07-2008
Quote:
Originally Posted by fpmurphy
The following code snippet works on ksh-93 and bash-3.2

Code:
$ INPUT="~@#$%^\&*()-_=+{}[]\\\|;:<>,.\/?"
$ echo $INPUT
~@#$%^\&*()-_=+{}[]\|;:<>,.\/?
$ cat file
111 head 222
333 head 444
$ sed "s/head/${INPUT}/" file
111 ~@#$%^&*()-_=+{}[]\|;:<>,./? 222
333 ~@#$%^&*()-_=+{}[]\|;:<>,./? 444
$

Thank you, any idea how can can add \\ for \ in input. \ for / in input use sed?

shamrock wrote: sed -e "sQword_to_replaceQ${INPUT}Q" -e "s/\(\^\)word_to_replace\(\*\)/\1\2/"

and it return "~@#$%^&*()-_=+{}[]|;:<>,./?" instead of "~@#$%^&*()-_=+{}[]\|;:<>,./?" so \ is missing
 

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

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

5. Infrastructure Monitoring

sed help,,kind of urgent!!

Hello All, My problem is: I want to replace a line from a file with sed. The first word in that line is always the same in every server. The second line is server model, which of course will vary from platform to platform and I need to leave that word as it is. After the second word, I need to... (3 Replies)
Discussion started by: solaix14
3 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
HEAD(1P)						     POSIX Programmer's Manual							  HEAD(1P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
head - copy the first part of files SYNOPSIS
head [-n number][file...] DESCRIPTION
The head utility shall copy its input files to the standard output, ending the output for each file at a designated point. Copying shall end at the point in each input file indicated by the -n number option. The option-argument number shall be counted in units of lines. OPTIONS
The head utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines. The following option shall be supported: -n number The first number lines of each input file shall be copied to standard output. The application shall ensure that the number option- argument is a positive decimal integer. When a file contains less than number lines, it shall be copied to standard output in its entirety. This shall not be an error. If no options are specified, head shall act as if -n 10 had been specified. OPERANDS
The following operand shall be supported: file A pathname of an input file. If no file operands are specified, the standard input shall be used. STDIN
The standard input shall be used only if no file operands are specified. See the INPUT FILES section. INPUT FILES
Input files shall be text files, but the line length is not restricted to {LINE_MAX} bytes. ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of head: LANG Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files). LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES . ASYNCHRONOUS EVENTS
Default. STDOUT
The standard output shall contain designated portions of the input files. If multiple file operands are specified, head shall precede the output for each with the header: " ==> %s <== ", <pathname> except that the first header written shall not include the initial <newline>. STDERR
The standard error shall be used only for diagnostic messages. OUTPUT FILES
None. EXTENDED DESCRIPTION
None. EXIT STATUS
The following exit values shall be returned: 0 Successful completion. >0 An error occurred. CONSEQUENCES OF ERRORS
Default. The following sections are informative. APPLICATION USAGE
The obsolescent - number form is withdrawn in this version. Applications should use the -n number option. EXAMPLES
To write the first ten lines of all files (except those with a leading period) in the directory: head * RATIONALE
Although it is possible to simulate head with sed 10q for a single file, the standard developers decided that the popularity of head on historical BSD systems warranted its inclusion alongside tail. This standard version of head follows the Utility Syntax Guidelines. The -n option was added to this new interface so that head and tail would be more logically related. There is no -c option (as there is in tail) because it is not historical practice and because other utilities in this volume of IEEE Std 1003.1-2001 provide similar functionality. FUTURE DIRECTIONS
None. SEE ALSO
sed, tail COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 HEAD(1P)
All times are GMT -4. The time now is 01:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy