LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-20-2005, 04:56 PM   #1
steve_f60
Member
 
Registered: Jul 2004
Posts: 43

Rep: Reputation: 15
? on editing a file


Hello,

I am trying to delele a line of text from a preferences file with no success. I tried using sed inside my script but to get the line deleted from the file I would have to redirect the file to a new output file, which breaks my symbolic links

Is there someway to use an editor to do this from a command line and keep the integrity of the file as is?

Thanks,

Steve
 
Old 09-20-2005, 05:20 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Are you trying to edit the file logged in as user, when the permissions require root authority? If so, open a term window and su to root, then edit using vim, emacs, or some other text editor.
 
Old 09-20-2005, 05:20 PM   #3
mickyg
Member
 
Registered: Oct 2004
Location: UK
Distribution: Ubuntu/Kubuntu
Posts: 249

Rep: Reputation: 30
I think either emacs or vi should be able to do this. I personally prefer emacs but try both.
 
Old 09-20-2005, 05:21 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
sed -i should do the word in-place if you have the right
version (and of course permissions on the file).

That said, removing the original, and moving the destination
file to the old name should make the symlinks usable again,
too ... not sure how you would break them?


Cheers,
Tink
 
Old 09-20-2005, 05:22 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
He's apparently using a script.

You do need to pipe output from SED to a new file, but that could be done with a temp file, like so:
Code:
TMPFILE=`mktemp`
cat infile | sed 's/ABC/XYZ/g' > $TMPFILE
cat $TMPFILE > infile #preserve symlink
rm $TMPFILE
Something along those lines should do it for you.
 
  


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
file editing newdummy Linux - Newbie 5 03-18-2005 07:16 PM
I want to recover a file that I was editing wilfman Linux - General 1 03-01-2004 12:57 PM
File editing digger Linux - Newbie 3 01-28-2004 03:42 PM
basic file editing dartania Linux - Newbie 1 09-21-2003 02:00 PM
Help Editing Sudoers File Rubicone Linux - Newbie 2 05-03-2002 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:39 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