LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2013, 03:04 PM   #1
reza_zah1991
Member
 
Registered: Mar 2013
Location: Qom , Iran
Distribution: opensuse,lubuntu
Posts: 32

Rep: Reputation: Disabled
Thumbs up meaning of regex


this command clear space from inputFile & create a new File without space with out.txt Name

sed -e 's/[\t ]//g;/^$/d' $inputFile > $out.txt

's/[\t ]//g;/^$/d'

what is it mean?
how can i expert in this expression?
 
Old 06-22-2013, 09:46 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Code:
s/[\t ]//g;/^$/d
  s    - substitute second for first
  [\t] - first is tab
       - second is nothing
  g    - global, don't stop at first one found
  ;    - there's more
  ^$   - empty line, start is next to end
  d    - delete
So this removes all tabs and blank lines.
 
Old 06-22-2013, 11:55 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by smallpond View Post
Code:
s/[\t ]//g;/^$/d
  s    - substitute second for first
  [\t] - first is tab
       - second is nothing
So this removes all tabs and blank lines.
The second character in the set is a space character. So, the command deletes tabs, spaces, and blank lines.

--- rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
Perl to find regex and print following 5 lines after regex casperdaghost Linux - Newbie 3 08-29-2010 08:08 PM
regex with sed to process file, need help on regex dwynter Linux - Newbie 5 08-31-2007 05:10 AM
Meaning of -R, --g, -G shipon_97 Linux - Newbie 1 11-23-2006 11:02 AM
Need a regex, I suck at regex's d3funct Programming 4 02-25-2002 08:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration