Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-16-2004, 05:39 AM   #1
LQ Newbie
Registered: Dec 2003
Distribution: Fedora Core
Posts: 14

Rep: Reputation: 0
Change Text-File through bash script

I have a textbased konfiguration file and i want to change some parameters like

displayname="XLS111 RedHat Cluster 1"

in line 20



with a bash-script.

I've never scripted bash before, but i shouldn't be too difficult ?
Old 12-16-2004, 07:28 AM   #2
Senior Member
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
sed 's/displayname=".*"/displayname="somethingelse"/' myconfigfile >myconfigfile.tmp
mv myconfigfile.tmp myconfigfile
Old 12-17-2004, 09:48 PM   #3
Registered: Dec 2004
Location: Hawaii
Distribution: Fedora & CentOS
Posts: 72

Rep: Reputation: 15
If you're a one-liner moron like me, consider this:

 perl -pi -e 's/displayname=".*"/displayname="somethingelse"/' myconfigfile


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
Bash script text replacement... matthurne Programming 4 06-07-2011 07:46 PM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 08:15 PM
bash script help to parse out text slack guy Linux - Newbie 3 12-30-2004 09:42 AM
Need help reading text file in bash script scilec Programming 3 11-25-2004 07:44 PM
Bash script - reading from text file twantrd Programming 4 11-24-2004 01:38 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration