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 07-29-2004, 02:43 AM   #1
xedios
Member
 
Registered: May 2004
Location: SLO
Distribution: RH9
Posts: 70

Rep: Reputation: 15
Question Need help with scripting


Hi all

If someone can help me with my problem I will bi very happy


I need to write a script witch increases a number in a file

ig. when i run it first will bi sn:1
when i run it the second time sn:2 an so on


If you can help me I will bi very very happy !


Thanks
 
Old 07-29-2004, 03:16 AM   #2
majalee
Member
 
Registered: Jul 2004
Location: India
Distribution: Ubuntu / OpenSuse
Posts: 54

Rep: Reputation: 15
script

just save the following with some file name, give it execute permissions and it will do the job for u..

########################
#!/bin/sh
if [ -a /tmp/hello ]
then
b=`cat /tmp/hello | cut -f2 -d:`
b=`expr $b + 1`
echo sn:$b > /tmp/hello
else
a=1
echo sn:$a > /tmp/hello
fi
########################

/tmp/hello is the file where u need the the "sn:1", "sn:2" to be there.

happy scripting..
aaditya
 
  


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
new to scripting mifan Linux - Newbie 2 08-17-2005 01:10 PM
another help with scripting?! ice99 Programming 2 08-09-2005 09:56 AM
Need help scripting Tamara Programming 7 06-06-2005 03:06 AM
Scripting Help Please Jazinator Linux - Newbie 7 10-17-2004 07:35 PM
scripting bforest Linux - Newbie 4 05-11-2004 03:45 AM


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