LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-06-2013, 08:20 PM   #1
zkyzky
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Rep: Reputation: Disabled
storing data into text file


Hi, i would like to store my gross wage into my text file in the fifth segment like ${Name},${ID},${HP},${Type}, ${wage}
what codes should i add for me to execute that.
Code:
line=`grep -i "$Name" $PAYROLL`
  Type=`echo $line | cut -d "," -f4`

if [[ $Type -eq $one ]];
then
echo "He is an Salaried employee"
echo "Enter hourly wage: "
read wage
echo "Enter hours worked this week: "
read hours
gross=`echo "$wage*$hours" | bc`
echo "Gross wages: $" $gross

elif [[ $Type -eq $two ]];
then
echo "He is an Hourly employee"
echo "Enter hourly wage: "
read wage
echo "Enter hours worked this week: "
read hours
gross=`echo "$wage*$hours" | bc`
echo "Gross wages: $" $gross
elif [[ "$Type" -eq $three ]];
then
echo "He is an Commission employee"
echo "Enter hourly wage: "
read wage
echo "Enter hours worked this week: "
read hours
gross=`echo "$wage*$hours" | bc`
sed -i.back
echo "Gross wages: $" $gross
else
echo "Unknown value for Type: $Type"
 
fi
#done
fi
 
Old 11-06-2013, 08:23 PM   #2
andrewthomas
Senior Member
 
Registered: May 2010
Location: Chicago Metro
Distribution: Arch, Gentoo, Slackware
Posts: 1,690

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
This sounds like a homework problem, no?
 
Old 11-06-2013, 08:47 PM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,
Quote:
Originally Posted by andrewthomas View Post
This sounds like a homework problem, no?
possibly.

We tried to help OP with this script over at http://www.linuxquestions.org/questi...on-4175483546/...

OP: again, please indent your code correctly (if you don't know what that means, either look it up or ask).

As for writing to files in a shell script, the simple way is to redirect the output of echo, using > or >> operators. Have a search online. Eg "bash output redirection".

Evo2.
 
  


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
Linux File Server storing data in DOS/WINDOWS format FineArt0104 Linux - Server 7 12-29-2011 05:58 AM
[SOLVED] Reading numbers from text file and storing in array idaham Linux - General 3 05-27-2010 04:36 AM
Reading a CSV text file and storing the values in Oracle Database table shafi2all Linux - Newbie 3 04-17-2008 01:19 PM
storing text in a text file for a specified length of time. mrobertson Programming 7 08-02-2005 11:27 AM


All times are GMT -5. The time now is 04:21 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration