Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 09-20-2005, 05:56 PM   #1
Registered: Jul 2004
Posts: 43

Rep: Reputation: 15
? on editing a file


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?


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

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
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, 06:20 PM   #3
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, 06:21 PM   #4
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
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?

Old 09-20-2005, 06:22 PM   #5
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
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:
cat infile | sed 's/ABC/XYZ/g' > $TMPFILE
cat $TMPFILE > infile #preserve symlink
Something along those lines should do it for you.


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

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

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
Open Source Consulting | Domain Registration