pydelion.com

pydelion.com

date –date="5 min ago" +%d/%b/%Y:%H:%M

Menu

Skip to content
  • about
  • devops links
  • dandelion
  • lion
  • contact

Tag Archives: sed

sed: replacing multiple empty lines with one

As simple as:

sed -e '/^$/N;/^\n$/D' <file>
Posted on April 11, 2016 by dandelion. Posted in linux | Tagged sed | Leave a comment

Passing bash variable to sed

If  you need to pass some variable from bash to sed use double quotes:

sed -i "s/$var/replace/g" "$file"

Easy.

Posted on April 16, 2013 by dandelion. Posted in tips | Tagged sed | Leave a comment

sed: remove a line / remove an empty line

To remove empty lines run:

sed '/^$/d' /home/dandelion/itsfile.txt

To remove lines matching the pattern:

sed '/patter/d' /home/dandelion/itsfile.txt

Add -i option to remove in a file itself, instead of printing the output to stdout.

 

Posted on February 21, 2013 by dandelion. Posted in tips | Tagged sed, tips | Leave a comment
  • FrançaisFrançais
  • EnglishEnglish
  • EspañolEspañol

Recent Posts

  • Debian: There is no public key available for the following key IDs
  • How to renew Certificate Revocation List
  • Dovecot: Error: mmap failed with file … dovecot.index.cache: Cannot allocate memory
  • Debian: reconfigure unattended upgrades
  • Curl: how to send cookies

Categories

  • linux
  • mysql
  • news
  • python
  • thoughts
  • tips
  • Uncategorized
  • weekly digests

Tags

adaptec ansible apt bash centos curl CORS debian distributed computing dovecot fedora galera html KVM linux memtest minify mysql mysqldump nagios openssl openvz percona perl php port forwarding postfix python qemu raid rpm ruby sed sinatra smtp svn tips trac traceroute ubuntu vim virsh vnstat weekly digest windows wordpress

Knowledge is knowing that a tomato is a fruit. Wisdom is knowing that a tomato doesn't belong in a fruit salad.
Miles Kington
Proudly powered by WordPress Theme: Publish by Konstantin Kovshenin.