@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> hi all, how can I in quick way delete all lines that begins with # from a fille?
<1> grep -v '#' file
<1> Nevermind.
<1> grep -v '^#' file
<0> newmanbe, thanks a lot, that was my point :D
<2> point? you mean question? :-/
<0> no sorry, I meant that I was looking for that answer :)
<2> ;-)
<3> /^#/d



<3> sed -e '/^#/d' ## the sed way
<3> Or sed -ne '/^#/!p' ## or this.
<2> live dangerously and add -i ;-)
<3> -i is illegal on my sed
<2> most of mine as well. i use gnu sed sometimes at work
<3> So funny story about when I first learned sed
<3> I was searching text files for a pattern and I realized I needed it to be case-insensitive.
<3> So, I did sed -i -e '/hello/!d' *.c
<3> And then, "OMG, what just happened??" It was a very sad day.
<2> oh lord!
<2> backups?
<3> Yeah, I had RCS copies.
<3> I lost my most recent changes though.
<2> at least the most recent changes are the ones that are still fresh on you mind ;-)
<3> ;)
<2> i'm probably fortunate that i didn't have -i in the beginning
<2> i'm sure i can still shoot myself in the foot tho :-/
<3> Yeah. I can't remember, but I'm certain I did sed -e 'blah' file >file at least once.
<3> Not really a sed snafu, but ... :)
<2> heh
<2> it is for these reasons that i try not to own data i can't live without ;-P
<4> hi, how do I make sed delete everything after the first occurence of some text?
<5> corn: everything to the end of line or end of file?
<4> end of line
<3> s/some text.*//
<4> alright
<3> s/\(some text\).*/\1/
<4> thank you
<3> In case you want to keep "some text"
<5> corn http://www.student.northpark.edu/pemente/sed/sed1line.txt AND sed.sf.net
<4> k
<6> Is there any way to count how many times a pattern appears inside a text file?
<5> man wc
<6> gnubien: what about wc
<6> ?
<5> wc - print newline, word, and byte counts for each file
<5> marinosi: grep -c "regex" filename



<6> gnubien: 1 . wc does not search about a pattern
<6> 2. grep -c counts the lines that contain the pattern.a pattern may appear in a line more than once
<5> marinosi: so the regex can appear multiple times in one line?
<6> yeap
<5> marinosi: and the regex is space separated from other words?
<5> or can it be embedded in other words?
<6> i want to search how many times the char " appears inside the text
<6> i dont know if it is "word
<5> ok, count the number of soft quote char in a file; soft quote is a "
<6> of course i can write a prog to do that perl or c but i would like to know if i can do that with the "known" tools
<5> marinosi: sed 's/[^"]//g' filename |wc -c #wc is not accurate
<5> sed 's/[^"]//g' filename |wc -m #wc is not accurate; count is +1 for each line
<5> marinosi: v=$(echo "abced\"eopdeocl\"gehje" |sed 's/[^"]//g' | wc -m); z=$(($v - 1)); echo "$z" #2 and accurate for 1 line
<6> gnubien
<5> yo
<6> it worked to me like that :
<6> (for the history)
<6> tr -sc '"' '\012' < test.txt| uniq -c
<5> marinosi: i see, nice
<6> thnx for your time
<5> yea, i learned alot too
<6> :D
<7> hello all
<8> hello
<9> does sed support expressions like (.{50}) to print out fifty characters?
<3> \{n,m\}
<9> prec: I mean 50 of a particular regex match, though
<9> I just gave . as a simple example
<3> Right, and I gave a general answer ... :)
<3> \{30,40\} to match from 30 to 40 of the preceeding "atom".
<9> Well, say you want to print out the last 10 chars on a line, or all chars if there are fewer than 10
<3> An atom can be a literal, or dot, or bracket expression, or a \(subexpression\)
<9> 's/^.*\(..........\)$/\1/' is kinda ugly ...
<3> So, to print the last 10 characters on a line, you must delete all but the last ten: s/.*\(.\{10\}\)/\1/
<9> I swear I tried that :/
<10> "Stop being a noobasaurus rex."
<9> blah, now it works
<9> now I gotta figure out what's different
<9> goldfish: I can't, it's in my nature
<3> gnused -r -e 's/.*(.{10})/\1/'
<10> Mine too :/
<3> Some people find that easier to read. Fie I say! :P
<10> hehe


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #sed
or
Go to some related logs:

ubuntu udev conflicts with hotplug
iptables conntrack pptp
#ldap
konqueror feature only available with hal gentoo
#gentoo
dolmans recipe
#ai
#xorg
#perl
#gentoo



Home  |  disclaimer  |  contact  |  submit quotes