LinuxQuestions.org
Visit Jeremy's Blog.
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 10-27-2006, 05:18 AM   #1
ztdep
Member
 
Registered: Jul 2005
Posts: 217

Rep: Reputation: 31
shell script language


Hi:
Would you like to provide me some good free references on the linux shell script language.
I encounter some problem when i want to find a variable value from a file and then modify its value.
for example, there is sentence says in the file a.dat

$veleciy=777*0.02542

now , i need to modify 777 to 600. how to do this.

Regards
 
Old 10-27-2006, 05:29 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Code:
set veleciy=`echo $veleciy | tr "777" "600"`
that'll change the 777 value in the variable veleciy to 600.

There's probably a more elegant way though...

edit: I haven't tested this.

Last edited by pwc101; 10-27-2006 at 05:32 AM.
 
Old 10-27-2006, 05:50 AM   #3
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Quote:
Originally Posted by pwc101
I haven't tested this.
No doubt about that

To find each line containing "$veleciy=" and replace each occurrence of "777" with "600" in all those lines, you can use
Code:
sed -i.bak '/\$veleciy=/{s/777/600/g}' filename
This will make a backup of the original file.
 
Old 10-27-2006, 05:53 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
it's been a long morning
 
Old 10-27-2006, 10:13 AM   #5
nayyares
Member
 
Registered: Oct 2006
Location: JNB, SA
Posts: 33

Rep: Reputation: 15
Hi,
Amazing when i tried this string at google:

shell scripting, pdf
 
Old 10-27-2006, 10:57 AM   #6
Fredde87
Member
 
Registered: Aug 2005
Posts: 158

Rep: Reputation: 30
Quote:
Originally Posted by nayyares
Hi,
Amazing when i tried this string at google:

shell scripting, pdf
What a coincident, I just typed morron and found a picture of you with a link to this thread.
 
Old 10-27-2006, 12:07 PM   #7
johnson_steve
Senior Member
 
Registered: Apr 2005
Location: BrewCity, USA (Milwaukee, WI)
Distribution: Xubuntu 9.10, Gentoo 2.6.27 (AMD64), Darwin 9.0.0 (arm)
Posts: 1,152

Rep: Reputation: 46
check out:

http://tldp.org/LDP/abs/html/
 
  


Reply


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
detect shell script language lorebett Programming 10 09-02-2006 11:15 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
difference between shell scripting and c language gadekishore Linux - Software 5 10-17-2005 06:33 AM
Convert shell scripts to other language vladmihaisima Programming 6 07-28-2005 02:25 AM
Change shell language linmix Linux - Software 9 07-26-2004 12:45 PM

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

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