05-10-2006
Issue altering end data
I have an inventory program that I would like to have the ability to go and change or alter the field data based on the item number as a key. I have the menu option set but at the end of the script process it just appends the changed data to the database rather than what I would like; which is to replace the current item number and fields that were changed in the menu.
Any advice would be appreciated.
The inventory change script is below.
#!/bin/bash
#===================================================
# Script Name: invadd
# By: jhaynes
# Date: 4-4-2006
# Purpose: Script loop to add inventory to the HC
# computing inventory list, while preventing
# duplicate item#.
# Command Line:invadd
#===================================================
trap "rm ~/tmp/* 2> /dev/null ; exit" 0 1 2 3
invfile=~/final/hc_inventory
looptest=y
while [ $looptest = "y" ]
do
clear
tput cup 25 4; ./appendinv;
tput cup 1 4; echo "HC Inventory Change"
tput cup 2 4; echo "================================"
tput cup 4 4; echo "Item Number: "
tput cup 5 4; echo "Description: "
tput cup 6 4; echo "Dept : "
tput cup 7 4; echo "Cost : "
tput cup 8 4; echo "Qty : "
tput cup 10 4; echo "Add Another? (y)es or (q)uit: "
tput cup 11 4; echo "Please enter an item number or q to quit "
tput cup 4 16; read itemnum
if [ "$itemnum" = 'q' ]
then clear ; exit
fi
#Check to make sure the Item number field is not blank
if [ "$itemnum" = "" ]
then
tput cup 11 2; echo "***Item number can not be blank*** "
tput cup 13 2; echo "******Hit ENTER to continue******"
tput cup 4 16 ; echo " "
tput cup 4 16 ; read itemnum
continue
fi
tput cup 5 16; read descr
while [ "$descr" = '-' ]
do
tput cup 4 16 ; echo " "
tput cup 4 16 ; read itemnum
if [ "$itemnum" = 'q' ]
then
clear ; exit
fi
tput cup 5 16 ; read descr
done
tput cup 6 16; read dept
while [ "$dept" = '-' ]
do
tput cup 5 16 ; echo " "
tput cup 5 16 ; read descr
if [ "$descr" = 'q' ]
then
clear ; exit
fi
tput cup 6 16 ; read dept
done
tput cup 7 16 ; read cost
while [ "$cost" = '-' ]
do
tput cup 6 16 ; echo " "
tput cup 6 16 ; read dept
if [ "$dept" = 'q' ]
then
clear ; exit
fi
tput cup 7 16 ; read cost
done
tput cup 8 16 ; read qty
while [ "$qty" = '-' ]
do
tput cup 7 16 ; echo " "
tput cup 7 16 ; read cost
if [ "$cost" = 'q' ]
then
clear ; exit
fi
tput cup 8 16 ; read qty
done
#Check to make sure fields are not blank before you write the data4
if [ "$itemnum:$descr:$dept:$cost:$qty" > " " ]
then
echo "$itemnum:$descr:$dept:$cost:$qty" >> $invfile
fi
tput cup 10 33; read looptest
if [ "$looptest" = 'q' ]
then
clear ; exit
fi
done
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to change a number in a file into number -1..
for instance
file_input is
fdisdlf_s35
fdjsk_s27
fsdf_s42
jkljllljkkl_s57
... etc
now i want the output to be
fdisdlf_s34
fdjsk_s26
fdsf_s41
jkljllljkkl_s56
... etc
I was think of using "sed -e 's/2/1/g' -e 's/3/2/g' -e... (4 Replies)
Discussion started by: bigboizvince
4 Replies
2. Shell Programming and Scripting
Hello,
I am getting few text files with no EOF ( or end-of-line ) which i need to fix using a command so that i can include it in a script. Now i'm fixing this issue by opening the file in "vi" editor and adding last line.
e.g.,
server1#wc -l temp.txt
9 temp.txt
server1#cat ... (6 Replies)
Discussion started by: prvnrk
6 Replies
3. Shell Programming and Scripting
Example,
Trying to replace text to the end of a line.
Text file looks like this
PP= 4
PP= 412
PP= 425
I want to replace only the following line:
PP= 4
with
PP= 2
How can this be done with sed? (3 Replies)
Discussion started by: hanson397
3 Replies
4. Shell Programming and Scripting
Hi Experts,
I want to alter two filed of my data file: The _new should come to 2nd column, and _new to be removed from 4rth column, please advise,
datafile.txt
aa /dev/vgAA/lvol1 bb /dev/vgAA_new/lvol1
aa /dev/vgAA1/lvol2 bb /dev/vgAA1_new/lvol2
aa /dev/vgAC/lvol1 bb... (5 Replies)
Discussion started by: rveri
5 Replies
5. UNIX for Dummies Questions & Answers
Hi All,
I have a sample datafile:
5.1
5.2
0.8
6.1
What I want to do is create an additional 3 rows with the number "0.7". so that I now have:
5.1
5.2
0.8
6.1
0.7
0.7 (3 Replies)
Discussion started by: tintin72
3 Replies
6. Shell Programming and Scripting
I have searched the forms and I can not find info on appending each line of one file to the same line of another file. I know that I can cat one file to another or append the 2nd file to the end of the 1st but not quite sure how to append one line of data to another. For example
File 1 has ... (2 Replies)
Discussion started by: scw132
2 Replies
7. Shell Programming and Scripting
I have a file which has data in the below format:
7810902|6783014102| || |0| |0| |0| |0|||||T|04/13/2006||9423|7421||100|2006-04-13 16:50:28|||2006-04-13 16:50:28|n|51|-1||214
1089929|||||NewSpCreateAction request successful. Activity ID = <826528>||||100|n|2006-04-13 16:50:27|2006-04-13... (3 Replies)
Discussion started by: ankianand88
3 Replies
8. Shell Programming and Scripting
Can I take an argument input, lets say it's, hg0000_xy1_v2, in the script it becomes f ... then hack off the end of the filename to change the variable to hg0000 only.
I tried using sed but can't figure it out.
f="$f" | sed 's/_fg_v//'
I could change the variable label if necessary to... (4 Replies)
Discussion started by: scribling
4 Replies
9. Programming
I have a script I am trying to test and run but it runs against a jar file. I wrote an external property file so it would redirect with my script, but it keeps going in search of the previous property file. Is there any way to externally over write the jar file and if not how do you go about... (7 Replies)
Discussion started by: risarose87
7 Replies
10. Shell Programming and Scripting
I have two files
fileA
HEADER LINE A
CommentLine A
Content A
....
....
....
TAILER AfileB
HEADER LINE B
CommentLine B
Content B
....
....
....
TAILER BI want to merge these two files as
HEADER LINE A
CommentLine A
Content A (4 Replies)
Discussion started by: sam05121988
4 Replies