LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-03-2007, 02:18 AM   #1
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Rep: Reputation: 30
Remove specific text in output line


Anyone knows how to remove specific text in a output in line?
 
Old 07-03-2007, 02:37 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
grep -v is the normal way in my world. some context would be nice though. probably best to suggest you just read through the grep manpage...
 
Old 07-03-2007, 10:19 PM   #3
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Original Poster
Rep: Reputation: 30
tried with "grep -v", it helps to grep lines which is exclude the text we filter

I am looking for a way to remove the text in a line.
Example: This is a testing line
I would like to make the final line with the word "This is a test line"

Can I know how can we do this?
 
Old 07-03-2007, 11:05 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
In that case you might want to try "sed"
Code:
sed -i -e 's/testing/test/'  /path/to/file
might get you started.
Lots of good tutorials around.
 
Old 07-04-2007, 12:00 AM   #5
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Original Poster
Rep: Reputation: 30
Please find the below scenario

Steps
------
1) search a file call abc.txt
command: find / -name abc.txt
example output: /tmp/testfile/abc.txt

2) Obtain the directory for the file location
command: ???
example output: /tmp/testfile/

Since the file location for abc.txt could be dynamic. Can I know is there anyway to find a file and then we obtain the path of the file?

Really appreciate if someone can help on this.
 
Old 07-04-2007, 02:20 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well we're not here to do your homework for you, which this really looks like. you need to study yourself... i'll tell you that there is a dedicated standard bash command to do exactly that though.
 
Old 07-04-2007, 02:33 AM   #7
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Original Poster
Rep: Reputation: 30
I had tested with grep, awk and sed which also didnt work for my case.
If there is a standard bash command to do it, would you mind to share with me?
 
Old 07-04-2007, 11:05 AM   #8
dawkcid
Member
 
Registered: May 2007
Location: UK
Distribution: LFS,Slackware,Slamd64,NetBSD
Posts: 102

Rep: Reputation: 15
As acid_kewpie said, you need to do your own homework. But here's a hint:
man bash, lookup the section 'Parameter Expansion'
 
Old 07-04-2007, 11:28 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well yes, that's certainly one way, not the way i was thinking off at all though. so many ways... so little probelms
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SED - replace text in file on specific line 3saul Linux - Software 1 03-04-2006 07:01 PM
vb.net writing to a specific line in a text file mrobertson Programming 3 12-30-2005 10:24 PM
Writing to a specific line in a text file mrobertson Programming 6 12-30-2005 04:02 PM
SED - display text on specific line of text file 3saul Linux - Software 3 12-29-2005 04:32 PM
bash-script: output text between two ocurrences of a specific string isl01jbe Programming 1 06-17-2004 02:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:45 PM.

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