Archive | August 2012

Delete file contents using ‘sed’

[Sed] Delete one or more lines from a file

Here is how to remove one or more lines from a file.


sed '{[/]<n>|<string>|<regex>[/]}d' <fileName>      
sed '{[/]<adr1>[,<adr2>][/]d' <fileName>
  • /…/=delimiters
  • n = line number
  • string = string found in in line
  • regex = regular expression corresponding to the searched pattern
  • addr = address of a line (number or pattern )
  • d = delete


Remove the 3rd line:

sed '3d' fileName.txt

Remove the line containing the string “awk”:

sed '/awk/d' filename.txt

Remove the last line:

sed '$d' filename.txt

Remove all empty lines:

sed '/^$/d' filename.txt      
sed '/./!d' filename.txt

Remove the line matching by a regular expression (by eliminating one containing digital characters, at least 1 digit, located at the end of the line):

sed '/[0-9/][0-9]*$/d' filename.txt

Remove the interval between lines 7 and 9:

sed '7,9d' filename.txt

The same operation as above but replacing the address with parameters:

sed '/-Start/,/-End/d' filename.txt

The above examples are only changed at the display of the file (stdout1= screen).

For permanent changes to the old versions (<4) use a temporary file for GNU sed using the “-i[suffix]”:

sed -i".bak" '3d' filename.txt

How to do Advanced file search in Windows 7?

Here’s a list of search filters you can Type into the search box to narrow things down:

Filter Explanation
kind: This will only search for files of the type that you specify.  Some examples are document, folder, picture, and calendar.
datemodified: This will search for anything based on the date that they were last modified.
Note that the mini-calendar will allow you to Select a range of dates if you hold down the Shift key.
datetaken: Searches for photos based on the day they were captured.
datecreated: Searches for anything created on the specified date or time range.
name: Windows will only search for files by their name, not contents.
type: This will search for files of a specified extension. Some examples are .bmp, .pdf, .doc, and .mp3.  This is similar to the “kind:” filter, but much more specific.
tags: This will search for files based on the metadata tags that are included in the file.
size: Search for a file of a specific size, or you can broaden the search by looking for a range of sizes.  To make a custom range, put two periods in-between variables.  For example:
length: Searches for audio and video clips by length.
authors: You can enter the username of the person who created a file, and search will only display results by that user.

Essential Repositories for RedHat(RHEL)/Fedora/CentOS

  • EPEL:  Extra Packages for Enterprise Linux (or EPEL) is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL),CentOS and Scientific Linux (SL).
  • RPMforge: RPMforge is a collaboration of Dag and other packagers. They provide over 5000 packages for CentOS, including wine, vlc, mplayer, xmms-mp3, and other popular media tools. It is not part of Red Hat or CentOS but is designed to work with those distributions.
  • RPM Fusion :RPM Fusion provides software that the Fedora Project or Red Hat doesn’t want to ship. That software is provided as precompiled RPMs for all current Fedora versions and Red Hat Enterprise Linux 5 and 6; you can use the RPM Fusion repositories with tools like yum and PackageKit.RPM Fusion is a merger of DribbleFreshrpms, and Livna; our goal is to simplify end-user experience by grouping as much add-on software as possible in a single location.
%d bloggers like this: