Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 03-18-2005, 10:53 AM   #1
LQ Newbie
Registered: Mar 2005
Location: markham, ontario
Posts: 6

Rep: Reputation: 0
question on sed

I have a file (file01) with several words that I need to output to another file (file02). I need file02 to be formated to a single column, will all non-alphabet characters removed, except for dash (-) and appostrophe (') characters.

When I use the following, it formats correcly and removes all non-alphabet characters (including ' and -)

tr ' ' '\n' <$FILEDIR/file01 | sed -e 's/[^a-z A-Z]//;/^$/ d' >$FILEDIR/file02

When I try to specify the exclusion of ' and - characters as in below, the command fails. What am I doing wrong?

tr ' ' '\n' <$FILEDIR/file01 | sed -e 's/[^a-z A-Z]//;s/[']//; s/[\-];/^$/ d' >$FILEDIR/file02


Old 03-18-2005, 01:14 PM   #2
Senior Member
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Try escaping the ' in ['] with a backslash.
Old 03-18-2005, 01:27 PM   #3
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 377Reputation: 377Reputation: 377Reputation: 377
i believe the issue has been resolved in this thread's twin:
Old 03-18-2005, 04:38 PM   #4
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,632

Rep: Reputation: 208Reputation: 208Reputation: 208
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

The problem is solved in the Programming forum: and this thread is closed.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
sed question ckoniecny Linux - General 3 11-11-2005 09:31 AM
sed question sphynx Programming 6 04-28-2004 06:25 PM
little sed question freelinuxcpp Linux - Software 3 01-20-2004 07:36 AM
sed question zoomzoom Linux - Software 2 10-20-2003 04:04 PM
A question on 'sed' Barbarian Programming 4 04-11-2002 10:19 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:13 AM.

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