Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write to a text file in #!/bin/sh

Status
Not open for further replies.

gsopitan

MIS
Oct 14, 2008
5
US
I am creating a command that does the following;

commandname increment file num

file contains an integer
num is an integer

I want my command to add the value of arg2 to the content arg1

I was thinking;

#!/bin/sh

for $3 in ![0-9] # I am not even sure this would work
do
echo 1>&2 Error: You must enter an integer value
exit 5
done

# This is where I am completely lost. I am not sure how to write the value of "num" + `cat file` in "file"

Any help would be greatly appreciated.

Thanks
 
This sounds like a class assignment, so please don't ask us to code it for you. Your code example says "I am not even sure this would work". Well what have you actually tried on a system? And what were the results or error messages?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top