Sponsored Content
Top Forums Shell Programming and Scripting sed command not getting the right output Post 302964314 by jozo95 on Wednesday 13th of January 2016 11:14:08 AM
Old 01-13-2016
Quote:
Originally Posted by RudiC
Code:
sed 
        -n      switch off default print
        E       sw. on extended regexes
        's      substitute command
        /^      start of line
        [^-<>]* any sequence of non "-", non "<", non ">" chars   
        |       alternate regex separator ("OR" regexes)
        [^:]*   seq of non ":" chars
        [:-<>]* any combination of "-><:" chars
        [^:]*$  seq of non ":", EOL  
        //      empty replacement string
        g       global flag (substitute ALL occurrences)
        p       print if substitution took place
' file

I love you sir. I have a question on the " [^-<>]* ", the "^" here is the same as "!" (dont)? And why is the g flag needed ?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using grep output as input for sed command

Hi, I would like to know if this is possible, and if so what can i do to make this work. I would like to grep a line X from fileA and then use the output to replace a word Y in fileB. grep "line X" fileA | sed -e 's/Y/X/g' > outfile this statement does not work, as i do not know how to... (7 Replies)
Discussion started by: cavanac2
7 Replies

2. Shell Programming and Scripting

sed command works from cmd line to standard output but will not write to file

Hi all .... vexing problem here ... I am using sed to replace some special characters in a .txt file: sed -e 's/_<ED>_/_355_/g;s/_<F3>_/_363_/g;s/_<E1>_/_341_/g' filename.txt This command replaces <ED> with í , <F3> with ó and <E1> with á. When I run the command to standard output, it works... (1 Reply)
Discussion started by: crumplecrap
1 Replies

3. Shell Programming and Scripting

Help needed with file output awk sed command - please

Hi I have a file that contains lines starting with a particular string plus a Colon: I need to output all these lines but only what comes after the colon Can you pelase assist? Example of lines in the file: com.ubs.f35.cashequities/cashequities: 1 2 ... (5 Replies)
Discussion started by: mnassiri
5 Replies

4. Shell Programming and Scripting

Abnormality while piping tr command output to sed

i have a file seperated each line seperated by newline. For example alpha beta gamma i am trying to replace the newlines to "," but dont want , present at the end of the line so i am trying the below one liner . but not sure whats wrong but its not working cat myfile | tr -s '\n' ',' | sed... (9 Replies)
Discussion started by: chidori
9 Replies

5. Shell Programming and Scripting

How to append a value to the output after using sed command?

Hi All, I have a file where I am converting newlines to comma separated values but I would like to append zero if the output is empty Here is the command I am using sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}' test1.txt test1.txt will have comma seperated values but sometimes this file can be... (6 Replies)
Discussion started by: rajeevm
6 Replies

6. UNIX for Dummies Questions & Answers

Output of sed command to another sed command

Hi All, I'm relatively new to Unix scripting and am trying to get my head around piping. I'm trying to take a header record from one file and prepend it to another file. I've done this by creating several temp files but i'm wondering if there is a cleaner way to do this. I'm thinking... (10 Replies)
Discussion started by: BigCroyd
10 Replies

7. Shell Programming and Scripting

Help with Passing the Output of grep to sed command - to find and replace a string in a file.

I have a file example.txt as follows :SomeTextGoesHere $$TODAY_DT=20140818 $$TODAY_DT=20140818 $$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script. (It would even be better if I could pass... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

8. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

9. Shell Programming and Scripting

sed command is saving output as blank file

Hi, I am working on a script where I am adding adding colors to few of the info in the output. Now , after that is done , I see colour codes in log files which I don't want to see.:mad::mad::mad::mad: So , I tried using sed command in script as below which gives me o/p (new.log) as blank file... (7 Replies)
Discussion started by: Dream4649
7 Replies

10. UNIX for Dummies Questions & Answers

sed Command Output

I want to know how this command output will be sed 's/^"\(.*\)"$/\1/' <filename> (3 Replies)
Discussion started by: abhilashnair
3 Replies
Regexp::Common::list(3) 				User Contributed Perl Documentation				   Regexp::Common::list(3)

NAME
Regexp::Common::list -- provide regexes for lists SYNOPSIS
use Regexp::Common qw /list/; while (<>) { /$RE{list}{-pat => 'w+'}/ and print "List of words"; /$RE{list}{-pat => $RE{num}{real}}/ and print "List of numbers"; } DESCRIPTION
Please consult the manual of Regexp::Common for a general description of the works of this interface. Do not use this module directly, but load it via Regexp::Common. $RE{list}{-pat}{-sep}{-lastsep} Returns a pattern matching a list of (at least two) substrings. If "-pat=P" is specified, it defines the pattern for each substring in the list. By default, P is "qr/.*?S/". In Regexp::Common 0.02 or earlier, the default pattern was "qr/.*?/". But that will match a single space, causing unintended parsing of "a, b, and c" as a list of four elements instead of 3 (with "-word" being "(?:and)"). One consequence is that a list of the form "a,,b" will no longer be parsed. Use the pattern "qr /.*?/" to be able to parse this, but see the previous remark. If "-sep=P" is specified, it defines the pattern P to be used as a separator between each pair of substrings in the list, except the final two. By default P is "qr/s*,s*/". If "-lastsep=P" is specified, it defines the pattern P to be used as a separator between the final two substrings in the list. By default P is the same as the pattern specified by the "-sep" flag. For example: $RE{list}{-pat=>'w+'} # match a list of word chars $RE{list}{-pat=>$RE{num}{real}} # match a list of numbers $RE{list}{-sep=>" "} # match a tab-separated list $RE{list}{-lastsep=>',s+ands+'} # match a proper English list Under "-keep": $1 captures the entire list $2 captures the last separator $RE{list}{conj}{-word=PATTERN} An alias for $RE{list}{-lastsep=>'s*,?s*PATTERNs*'} If "-word" is not specified, the default pattern is "qr/and|or/". For example: $RE{list}{conj}{-word=>'et'} # match Jean, Paul, et Satre $RE{list}{conj}{-word=>'oder'} # match Bonn, Koln oder Hamburg $RE{list}{and} An alias for $RE{list}{conj}{-word=>'and'} $RE{list}{or} An alias for $RE{list}{conj}{-word=>'or'} SEE ALSO
Regexp::Common for a general description of how to use this interface. AUTHOR
Damian Conway (damian@conway.org) MAINTAINANCE
This package is maintained by Abigail (regexp-common@abigail.be). BUGS AND IRRITATIONS
Bound to be plenty. For a start, there are many common regexes missing. Send them in to regexp-common@abigail.be. LICENSE and COPYRIGHT This software is Copyright (c) 2001 - 2009, Damian Conway and Abigail. This module is free software, and maybe used under any of the following licenses: 1) The Perl Artistic License. See the file COPYRIGHT.AL. 2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2. 3) The BSD Licence. See the file COPYRIGHT.BSD. 4) The MIT Licence. See the file COPYRIGHT.MIT. perl v5.16.2 2010-02-23 Regexp::Common::list(3)
All times are GMT -4. The time now is 03:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy