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!
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
07-29-2009, 07:08 AM
#1
LQ Newbie
Registered: Jul 2009
Posts: 13
Rep:
add text to end of line?
I had to do this:
i want to add a text of each line, but not when the word REJECTED is the last word in the line.
the text is (tab = user tabulator)
<tab> OK
i know i can add with 'sed' the text but how to check if the line ends with 'REJECTED' ?
07-29-2009, 07:30 AM
#2
Member
Registered: Jul 2009
Distribution: Ubuntu 9.04
Posts: 325
Rep:
/REJECTED$/ will match a line ending with REJECTED, the dollar sign being the end of the line ...
07-29-2009, 07:32 AM
#3
Senior Member
Registered: Dec 2008
Location: Gorizia, Italy
Distribution: Debian Testing Amd64
Posts: 2,776
Rep:
This wouldn't be homework, would it?
jdk
07-29-2009, 07:36 AM
#4
Senior Member
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137
Rep:
Quote:
Originally Posted by
tatoosh
I had to do this:
i want to add a text of each line, but not when the word REJECTED is the last word in the line.
the text is (tab = user tabulator)
<tab> OK
i know i can add with 'sed' the text but how to check if the line ends with 'REJECTED' ?
Code:
perl -pi.bak -e 's/oldstring$/newstring/g' file
perl in line edit. .bak for saving orig file
07-29-2009, 07:39 AM
#5
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: back to Arch
Posts: 16,662
sed '/REJECTED$/!s/$/new ending/' filename > newfilename
07-29-2009, 07:43 AM
#6
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: back to Arch
Posts: 16,662
Quote:
Originally Posted by
jdkaye
This wouldn't be homework, would it?
jdk
I guessed "no" because of posting history. Of course it could ALL be homework.......
07-30-2009, 07:21 AM
#7
LQ Newbie
Registered: Jul 2009
Posts: 13
Original Poster
Rep:
thanks for helping. i used another way so solve my problem.
07-31-2009, 03:15 AM
#8
Senior Member
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137
Rep:
Quote:
Originally Posted by
tatoosh
thanks for helping. i used another way so solve my problem.
share then...after all, you did ask for help..
07-31-2009, 03:28 AM
#9
LQ Newbie
Registered: Jul 2009
Posts: 13
Original Poster
Rep:
i used not this way. anyway - here is my part of script for the question:
it cleans my postmap file - so i dont need the "reject" thing i asked for.
Code:
#clean up
sed -e 's/[ \t]*OK/ \tOK/' $1 > $temp_file
mv $temp_file $1 -f
sed -e 's/[ \t]*OK[ ]/ \tOK/' $1 > $temp_file
mv $temp_file $1 -f
sed -e 's/[ \t]*Ok/ \tOK/' $1 > $temp_file
mv $temp_file $1 -f
#lowercase <MAILLIST>
cat $1 | tr "[A-Z]" "[a-z]" > $temp_file
mv $temp_file $1 -f
Thread Tools
Search this Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -5. The time now is 03:05 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News