Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Can someone please explain sed -n '/^$/!{s/<[^>]*>//g;p;}' filename Post 302612837 by maximus73 on Monday 26th of March 2012 11:29:55 AM
Old 03-26-2012
Can someone please explain sed -n '/^$/!{s/<[^>]*>//g;p;}' filename

I came across this sed expression, and it does exactly what I want.
However I haven't got the faintest clue how it does it and thus do not feel capable of using it.

Can someone please explain how this expression works?
(I used it to remove html tags in a html file I was converting to text)

sed -n '/^$/!{s/<[^>]*>//g;p;}' filename


The more detail the more I love you :-)
Thanks heaps,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed / shell - how to use $filename

I've forgotten how to use a filename parameter using sed inside a shell script. What I want to do is replace a string inside a file with the name of the file being processed. I think this should work .. for filename do sed -e "s/xxx/$filename/" ... ... done Thanks! Ps: ... (5 Replies)
Discussion started by: eadie
5 Replies

2. Shell Programming and Scripting

please explain this sed shell script to remove C++ comments.

#! /bin/sed -nf # Remove C and C++ comments, by Brian Hiles (brian_hiles@rocketmail.com) # Sped up (and bugfixed to some extent) by Paolo Bonzini (bonzini@gnu.org) # Works its way through the line, copying to hold space the text up to the # first special character (/, ", '). The original... (1 Reply)
Discussion started by: Priyaranjan
1 Replies

3. Shell Programming and Scripting

Explain SED code

Hi, Can anyone pls explain me the below SED code in detail. sed -e :a -e '$!N;s/\n//;ta' -e P -e D When this code is executed with a file(has 1lac records), it is taking very long time to process. So I wanted to modify this SED code with equivalant AWK code. Thanks, Sri (1 Reply)
Discussion started by: srilaxmi
1 Replies

4. Shell Programming and Scripting

How to use a dynamic filename with sed?

I have a line that works for static filename cat /directorypath/filename | sed '//d;//d' > filename This approach when used in a script works well. Then i need a list of filenames to give this line. I can get the list into a file by filelist1='ls -m' then use filelist2=${filelist1##ls... (4 Replies)
Discussion started by: ericonanson
4 Replies

5. Shell Programming and Scripting

sed -e 's%/$%%' explain this command

mount -ps | tail -1 | awk '{print $1}' | sed -e 's%/$%%' can you please explain this command mainly sed -e 's%/$%%' this.... (5 Replies)
Discussion started by: rsivasan
5 Replies

6. Shell Programming and Scripting

Explain following sed syntax please

Thanks to this forum I have managed to work out a solution to my problem and actually understand most of it, but one thing is confusing me and I am sure someone here can explain. I need to insert a piece of txt into a file. This txt is awk '{ sub(/$/,"\r"); print }' $JCL_WBB50103_EFTOUT >... (2 Replies)
Discussion started by: hukcjv
2 Replies

7. Shell Programming and Scripting

Please explain this SED expression

can anyone please explain this code? sed ':t /<VirtualHost/,/VirtualHost>/ { /VirtualHost>/!{ $!{ N; bt } }; /name/d; }' infile (4 Replies)
Discussion started by: jacky29
4 Replies

8. UNIX for Advanced & Expert Users

Please explain this sed one liner

Can anyone explain the below sed oneliner? sed -e ':a' -e '$q;N;11,$D;ba' It works same as tail command. I just want to know how it works. Thanks ---------- Post updated at 11:42 PM ---------- Previous update was at 11:37 PM ---------- Moderators, Can you please delete this thread?... (0 Replies)
Discussion started by: pandeesh
0 Replies

9. Shell Programming and Scripting

can you explain this sed code?

can anyone please explain this code? sed ':a;N;$!ba;s/]\n//g' file it replaces lines ending with "]" and concatenates with the next line so that line1] line2 becomes line1line2 i don't understand this part: :a;N;$!ba; I have noted that I can replace "a" with any letter: ... (1 Reply)
Discussion started by: locoroco
1 Replies

10. Shell Programming and Scripting

Explain sed command

sed -e 's,*$,,' Can someone explain the options in this command? (2 Replies)
Discussion started by: scj2012
2 Replies
SHTOOL-SUBST.TMP(1)					      GNU Portable Shell Tool					       SHTOOL-SUBST.TMP(1)

NAME
shtool-subst - GNU shtool sed(1) substitution operations SYNOPSIS
shtool subst [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning] [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup ext] [-e|--exec cmd] [-f|--file cmd-file] [file] [file ...] DESCRIPTION
This command applies one or more sed(1) substitution operations to stdin or any number of files. OPTIONS
The following command line options are available. -v, --verbose Display some processing information. -t, --trace Enable the output of the essential shell commands which are executed. -n, --nop No operation mode. Actual execution of the essential shell commands which would be executed is suppressed. -w, --warning Show warning on substitution operation resulting in no content change on every file. The default is to show a warning on substitution operations resulted in no content change on all files. -q, --quiet Suppress warning on substitution operation resulting in no content change. -s, --stealth Stealth operation. Preserve timestamp on file. -i, --interactive Enter interactive mode where the user has to approve each operation. -b, --backup ext Preserve backup of original file using file name extension ext. Default is to overwrite the original file. -e, --exec cmd Specify sed(1) command directly. -f, --file cmd-file Read sed(1) command from file. EXAMPLE
# shell script shtool subst -i -e 's;(c) ([0-9]*)-2000;(c) 1-2001;' *.[ch] # RPM spec-file %install shtool subst -v -n -e 's;^(prefix=).*;1 $RPM_BUILD_ROOT%{_prefix};g' -e 's;^(sysconfdir=).*;1 $RPM_BUILD_ROOT%{_prefix}/etc;g' `find . -name Makefile -print` make install HISTORY
The GNU shtool subst command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 2001 for GNU shtool. It was prompted by the need to have a uniform and convenient patching frontend to sed(1) operations in the OpenPKG package specifications. SEE ALSO
shtool(1), sed(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-SUBST.TMP(1)
All times are GMT -4. The time now is 05:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy