Sponsored Content
Top Forums Shell Programming and Scripting A sed doubt - need explanation Post 302237722 by Tytalus on Thursday 18th of September 2008 08:19:10 AM
Old 09-18-2008
Quote:
replaces all "/" characters with "_" for every line that starts with "."

well...not quite...and you can see that by running itSmilie...the fuller breakdown is:

Code:
sed "s        # substiute

%              # use % as delimiter, so we have %LHS%RHS% 
\([^.]\)/        # LHS i.e. pattern to work on - the \(..\) captures the interior pattern - which is [^.]\ i.e. anything that isn't a . , followed by the /
%
\1_            # this replaces what was in the brackes ( ), followed by a _
%
g"              # globally

i.e. ./ won't match, but all other X/ will, and will get replaced on the RHS by X_

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

doubt it sed

Hello.. i want to use variable in sed.. like sed 's/ROOTMAILID/$variable/g' conf.test but its not working.. please help thanks in advance esham (2 Replies)
Discussion started by: esham
2 Replies

2. UNIX for Dummies Questions & Answers

doubt in sed

hi all, i have a variable exported as VAR=ATTRIB then tried with, echo "tt" | sed 's/^/$VAR/' expected result as ttATTRIB but obtained only, $VARtt i could nt get where i am wrong. Thanks. (3 Replies)
Discussion started by: matrixmadhan
3 Replies

3. Shell Programming and Scripting

sed command explanation needed

Hi, Could you please explain me the below statement -- phrase wise. sed -e :a -e '$q;N;'$cnt',$D;ba' abc.txt > xyz.txt if suppose $cnt contains value: 10 it copies last 9 lines of abc.txt to xyz.txt why it is copying last 9 rather than 10. and also what is ba and $D over there in... (4 Replies)
Discussion started by: subbukns
4 Replies

4. Shell Programming and Scripting

Explanation for interesting sed behaviour?

This is my first post so hi to you all. I have browsed these forums in the past and what a great community and resource this is! Thanks to all the contributors ... I look forward to being able to give something back. In the meantime, I have a little conundrum concerning sed. My very simple... (6 Replies)
Discussion started by: Gavster
6 Replies

5. Shell Programming and Scripting

sed doubt...

Hi, i need find and replace a sting with a new variable having value as spaces in between. Eg: set a = "i am variable" set b = "i am second" sed -e 's/find_string/'$a'/g' -e 's/find2_str/'$b'/g' input_file here it is giving error... How to get an varaible, which is... (6 Replies)
Discussion started by: vasanth.vadalur
6 Replies

6. UNIX for Dummies Questions & Answers

SED command explanation

can someone please explain the below sed command.. sed 's/\(*|\)\(.*\)/\2\1/' (6 Replies)
Discussion started by: raghu_shekar
6 Replies

7. UNIX for Dummies Questions & Answers

Explanation of the command sed -n -e 's_.*>\(.*\)<.*_\1_p' filename.xml

Hi Friends, I am trying to modify a script .The script contains this line: sed -n -e 's_.*>\(.*\)<.*_\1_p' filename.xml I am not great in sed command.I know, it is regular expression to match a pattern string that starts with s_ and ends with 1_.I doesnot give the desired result. Can... (4 Replies)
Discussion started by: rajsharma
4 Replies

8. Shell Programming and Scripting

sed sorting command explanation

sed '$!N; /^\(.*\)\n\1$/!P; D' i found this file which removes duplicates irrespective for sorted or unsorted file. keep first occurance and remove the further occurances. can any1 explain how this is working.. i need to remove duplicates following file. duplicate criteria is not the... (3 Replies)
Discussion started by: mukeshguliao
3 Replies

9. UNIX for Dummies Questions & Answers

Doubt in sed

Hi All Can some one explain what does the given two sed commands do :confused: sed "s/\'/\\\'/g" | sed 's/\"/\\\"/g' Please find the sample code i used to find out what this is doing , but it has confused me more :wall: $ cat sri1.txt \ ' " $ sed 's/\"/\\\"/g' sri1.txt \ '... (5 Replies)
Discussion started by: Sri3001
5 Replies

10. Shell Programming and Scripting

sed command explanation

Will someone give me an explanation on how the sed command below works. sed 's/.*//' Thanks! (3 Replies)
Discussion started by: scj2012
3 Replies
FBB::TypeTrait(3bobcat) 					   Error handler					   FBB::TypeTrait(3bobcat)

NAME
FBB::TypeTrait - shortdesc SYNOPSIS
#include <bobcat/typetrait> DESCRIPTION
FBB::TypeTrait is a traits class. It does not define any member functions or data members, but merely types. It can be used to determine the basic type and other characteristics of (const) plain, (const) pointer or (const) reference types. It was designed after Alexandrescu's(2001) TypeTraits template class. The FBB::LpromotesR class template is used to determine, compile-time, whether its second (right-hand side) template type can be promoted to its first (left-hand side) template type. The FBB::Use class template expects two typenames LHS and RHS and defines typename Use<LHS, RHS>::type as LHS if RHS can be promoted to LHS or it defines typename Use<LHS, RHS>::type as RHS. NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
- TypeTrait<;TYPE> TYPE is the template type parameter whose characteristics must be determined. TypeTrait<TYPE> defines the type Plain: the plain type (the type without const, pointer, reference type indication) of any const or non-const plain, pointer, lvalue- or rvalue-reference type. TypeTrait<TYPE> defines the following bool values: o isClass: true if the template type argument represents a class (struct) type, false otherwise. o isConst: true if the template type argument represents a const type, false otherwise. o isPointer: true if the template type argument represents a pointer type, false otherwise. o isR_Ref: true if the template type argument represents a rvalue reference type, false otherwise. o isRef: true if the template type argument represents an lvalue reference type, false otherwise. LpromotesR<;LeftType, RightType> LpromotesR<LeftType, RightType> defines the enum constant yes as 1 if an RightType argument can be promoted to LeftType value or object. The enum value yes is defined as 0 if no such constructor is available or if such a constructor is defined using the explicit keyword. EXAMPLES
Here is an example using LpromotesR: int main() { cout << "string promotes char const *: " << LpromotesR<string, char const *>::yes << ' '; // 1 cout << "string promotes string " << LpromotesR<string, string>::yes << ' '; // 1 cout << "char const * promotes string " << LpromotesR<char const *, string>::yes << ' '; // 0 } FILES
bobcat/typetrait - defines the class interface SEE ALSO
bobcat(7) Alexandrescu A.(2001) Modern C++ Design, Addison-Wesley, Boston. BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::TypeTrait(3bobcat)
All times are GMT -4. The time now is 04:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy