How can I use an updating command to update my employees information in a shell script menu format? [on hold]
up vote
-1
down vote
favorite
I am creating an employee menu that will accept, update, search, display, and delete employee information. However, I can not seem to figure out how can I create a file that will let me update the employee’s specific information of my choosing using a shell script in vi
. For instance, a employee got married and I need to go in and change his/her last name. Or the employee moved to a different city, and I need to go in a change the employee city.
Here's an example of my search file:
#!/bin/bash
#====================================================================
# Script Name: eemployee
# By: DT
# Date: 11-06-2018
# Purpose: Searches for a specified employee in
# the employees file
#====================================================================
tumblingfile=~/CSCI3331/employees
clear
tput cup 5 1
echo "Enter Employee-ID to search for: "
tput cup 5 35
read number
echo
grep $number $tumblingfile | tr ':' ' '
echo
echo "Press ENTER to continue..."
read continue
shell-script awk sed vi
New contributor
put on hold as unclear what you're asking by Jesse_b, thrig, Jeff Schaller, mosvy, Thomas Nov 16 at 5:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-1
down vote
favorite
I am creating an employee menu that will accept, update, search, display, and delete employee information. However, I can not seem to figure out how can I create a file that will let me update the employee’s specific information of my choosing using a shell script in vi
. For instance, a employee got married and I need to go in and change his/her last name. Or the employee moved to a different city, and I need to go in a change the employee city.
Here's an example of my search file:
#!/bin/bash
#====================================================================
# Script Name: eemployee
# By: DT
# Date: 11-06-2018
# Purpose: Searches for a specified employee in
# the employees file
#====================================================================
tumblingfile=~/CSCI3331/employees
clear
tput cup 5 1
echo "Enter Employee-ID to search for: "
tput cup 5 35
read number
echo
grep $number $tumblingfile | tr ':' ' '
echo
echo "Press ENTER to continue..."
read continue
shell-script awk sed vi
New contributor
put on hold as unclear what you're asking by Jesse_b, thrig, Jeff Schaller, mosvy, Thomas Nov 16 at 5:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
I really hate to be the one to say it but shell scripts are a really bad tool for this. Regardless of what tool you end up using to accomplish this it's probably best to store this data in a database and not some sort of file.
– Jesse_b
Nov 15 at 21:48
Also, it’s not clear what your question is. You don’t say how you’re storing your data — is it one huge file, one small file per employee, multiple files for storing different aspects of the data (e.g., personal data vs. work-related data), or what? While we appreciate seeing what work you’ve already done, the script you’ve posted doesn’t tell us much, except it suggests that you have everything in one file. And you don’t say what your goal is — what do you need to do that you can’t do withvi "$tumblingfile"
?
– Scott
Nov 15 at 22:02
1
You could have each employee be represented by a directory whose name is the employee ID and have each attribute (name, location, salary) be a separate file. (I used this structure for a computer asset database.) If you have constraints on the structure of the file, please edit your question. If this is homework/quiz/exercise (CSCI3331 sounds like a university class), please edit the question to include the complete assignment.
– Mark Plotnick
Nov 15 at 22:02
CSCI3331 is my directory .... tumblingfile is my file name ... and "employees" is where all the employees information is stored inside my directory. my fields are $number , $lname, $city, $state, $zip, $annualsalary . I need help creating a shell script using vi editor to update a specific field of my choosing.
– Christina Tumbling
Nov 15 at 22:17
1
Please do not add information in comments; instead please edit your question to include the extra details. Speaking of details, your question is nigh-impossible to answer without knowing the specifications of how the 'employee' data are stored. SQLite? Flat file? CSV? Fixed-width table? Excel file run throughgzip
? An FLAC file containing a recording of the file being transferred through XMODEM at 9600 baud?
– DopeGhoti
Nov 15 at 22:33
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am creating an employee menu that will accept, update, search, display, and delete employee information. However, I can not seem to figure out how can I create a file that will let me update the employee’s specific information of my choosing using a shell script in vi
. For instance, a employee got married and I need to go in and change his/her last name. Or the employee moved to a different city, and I need to go in a change the employee city.
Here's an example of my search file:
#!/bin/bash
#====================================================================
# Script Name: eemployee
# By: DT
# Date: 11-06-2018
# Purpose: Searches for a specified employee in
# the employees file
#====================================================================
tumblingfile=~/CSCI3331/employees
clear
tput cup 5 1
echo "Enter Employee-ID to search for: "
tput cup 5 35
read number
echo
grep $number $tumblingfile | tr ':' ' '
echo
echo "Press ENTER to continue..."
read continue
shell-script awk sed vi
New contributor
I am creating an employee menu that will accept, update, search, display, and delete employee information. However, I can not seem to figure out how can I create a file that will let me update the employee’s specific information of my choosing using a shell script in vi
. For instance, a employee got married and I need to go in and change his/her last name. Or the employee moved to a different city, and I need to go in a change the employee city.
Here's an example of my search file:
#!/bin/bash
#====================================================================
# Script Name: eemployee
# By: DT
# Date: 11-06-2018
# Purpose: Searches for a specified employee in
# the employees file
#====================================================================
tumblingfile=~/CSCI3331/employees
clear
tput cup 5 1
echo "Enter Employee-ID to search for: "
tput cup 5 35
read number
echo
grep $number $tumblingfile | tr ':' ' '
echo
echo "Press ENTER to continue..."
read continue
shell-script awk sed vi
shell-script awk sed vi
New contributor
New contributor
edited Nov 15 at 21:47
Scott
6,58042650
6,58042650
New contributor
asked Nov 15 at 21:39
Christina Tumbling
1
1
New contributor
New contributor
put on hold as unclear what you're asking by Jesse_b, thrig, Jeff Schaller, mosvy, Thomas Nov 16 at 5:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by Jesse_b, thrig, Jeff Schaller, mosvy, Thomas Nov 16 at 5:55
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
2
I really hate to be the one to say it but shell scripts are a really bad tool for this. Regardless of what tool you end up using to accomplish this it's probably best to store this data in a database and not some sort of file.
– Jesse_b
Nov 15 at 21:48
Also, it’s not clear what your question is. You don’t say how you’re storing your data — is it one huge file, one small file per employee, multiple files for storing different aspects of the data (e.g., personal data vs. work-related data), or what? While we appreciate seeing what work you’ve already done, the script you’ve posted doesn’t tell us much, except it suggests that you have everything in one file. And you don’t say what your goal is — what do you need to do that you can’t do withvi "$tumblingfile"
?
– Scott
Nov 15 at 22:02
1
You could have each employee be represented by a directory whose name is the employee ID and have each attribute (name, location, salary) be a separate file. (I used this structure for a computer asset database.) If you have constraints on the structure of the file, please edit your question. If this is homework/quiz/exercise (CSCI3331 sounds like a university class), please edit the question to include the complete assignment.
– Mark Plotnick
Nov 15 at 22:02
CSCI3331 is my directory .... tumblingfile is my file name ... and "employees" is where all the employees information is stored inside my directory. my fields are $number , $lname, $city, $state, $zip, $annualsalary . I need help creating a shell script using vi editor to update a specific field of my choosing.
– Christina Tumbling
Nov 15 at 22:17
1
Please do not add information in comments; instead please edit your question to include the extra details. Speaking of details, your question is nigh-impossible to answer without knowing the specifications of how the 'employee' data are stored. SQLite? Flat file? CSV? Fixed-width table? Excel file run throughgzip
? An FLAC file containing a recording of the file being transferred through XMODEM at 9600 baud?
– DopeGhoti
Nov 15 at 22:33
add a comment |
2
I really hate to be the one to say it but shell scripts are a really bad tool for this. Regardless of what tool you end up using to accomplish this it's probably best to store this data in a database and not some sort of file.
– Jesse_b
Nov 15 at 21:48
Also, it’s not clear what your question is. You don’t say how you’re storing your data — is it one huge file, one small file per employee, multiple files for storing different aspects of the data (e.g., personal data vs. work-related data), or what? While we appreciate seeing what work you’ve already done, the script you’ve posted doesn’t tell us much, except it suggests that you have everything in one file. And you don’t say what your goal is — what do you need to do that you can’t do withvi "$tumblingfile"
?
– Scott
Nov 15 at 22:02
1
You could have each employee be represented by a directory whose name is the employee ID and have each attribute (name, location, salary) be a separate file. (I used this structure for a computer asset database.) If you have constraints on the structure of the file, please edit your question. If this is homework/quiz/exercise (CSCI3331 sounds like a university class), please edit the question to include the complete assignment.
– Mark Plotnick
Nov 15 at 22:02
CSCI3331 is my directory .... tumblingfile is my file name ... and "employees" is where all the employees information is stored inside my directory. my fields are $number , $lname, $city, $state, $zip, $annualsalary . I need help creating a shell script using vi editor to update a specific field of my choosing.
– Christina Tumbling
Nov 15 at 22:17
1
Please do not add information in comments; instead please edit your question to include the extra details. Speaking of details, your question is nigh-impossible to answer without knowing the specifications of how the 'employee' data are stored. SQLite? Flat file? CSV? Fixed-width table? Excel file run throughgzip
? An FLAC file containing a recording of the file being transferred through XMODEM at 9600 baud?
– DopeGhoti
Nov 15 at 22:33
2
2
I really hate to be the one to say it but shell scripts are a really bad tool for this. Regardless of what tool you end up using to accomplish this it's probably best to store this data in a database and not some sort of file.
– Jesse_b
Nov 15 at 21:48
I really hate to be the one to say it but shell scripts are a really bad tool for this. Regardless of what tool you end up using to accomplish this it's probably best to store this data in a database and not some sort of file.
– Jesse_b
Nov 15 at 21:48
Also, it’s not clear what your question is. You don’t say how you’re storing your data — is it one huge file, one small file per employee, multiple files for storing different aspects of the data (e.g., personal data vs. work-related data), or what? While we appreciate seeing what work you’ve already done, the script you’ve posted doesn’t tell us much, except it suggests that you have everything in one file. And you don’t say what your goal is — what do you need to do that you can’t do with
vi "$tumblingfile"
?– Scott
Nov 15 at 22:02
Also, it’s not clear what your question is. You don’t say how you’re storing your data — is it one huge file, one small file per employee, multiple files for storing different aspects of the data (e.g., personal data vs. work-related data), or what? While we appreciate seeing what work you’ve already done, the script you’ve posted doesn’t tell us much, except it suggests that you have everything in one file. And you don’t say what your goal is — what do you need to do that you can’t do with
vi "$tumblingfile"
?– Scott
Nov 15 at 22:02
1
1
You could have each employee be represented by a directory whose name is the employee ID and have each attribute (name, location, salary) be a separate file. (I used this structure for a computer asset database.) If you have constraints on the structure of the file, please edit your question. If this is homework/quiz/exercise (CSCI3331 sounds like a university class), please edit the question to include the complete assignment.
– Mark Plotnick
Nov 15 at 22:02
You could have each employee be represented by a directory whose name is the employee ID and have each attribute (name, location, salary) be a separate file. (I used this structure for a computer asset database.) If you have constraints on the structure of the file, please edit your question. If this is homework/quiz/exercise (CSCI3331 sounds like a university class), please edit the question to include the complete assignment.
– Mark Plotnick
Nov 15 at 22:02
CSCI3331 is my directory .... tumblingfile is my file name ... and "employees" is where all the employees information is stored inside my directory. my fields are $number , $lname, $city, $state, $zip, $annualsalary . I need help creating a shell script using vi editor to update a specific field of my choosing.
– Christina Tumbling
Nov 15 at 22:17
CSCI3331 is my directory .... tumblingfile is my file name ... and "employees" is where all the employees information is stored inside my directory. my fields are $number , $lname, $city, $state, $zip, $annualsalary . I need help creating a shell script using vi editor to update a specific field of my choosing.
– Christina Tumbling
Nov 15 at 22:17
1
1
Please do not add information in comments; instead please edit your question to include the extra details. Speaking of details, your question is nigh-impossible to answer without knowing the specifications of how the 'employee' data are stored. SQLite? Flat file? CSV? Fixed-width table? Excel file run through
gzip
? An FLAC file containing a recording of the file being transferred through XMODEM at 9600 baud?– DopeGhoti
Nov 15 at 22:33
Please do not add information in comments; instead please edit your question to include the extra details. Speaking of details, your question is nigh-impossible to answer without knowing the specifications of how the 'employee' data are stored. SQLite? Flat file? CSV? Fixed-width table? Excel file run through
gzip
? An FLAC file containing a recording of the file being transferred through XMODEM at 9600 baud?– DopeGhoti
Nov 15 at 22:33
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Better to do with sed command or awk command
Below commands working as per data mentioned in employees. Change the column number as per your data
Otherwise post sample data here
employees
city office name firstname lastname
mysore hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
command :
awk '/praveen/{$1="mandya";print}1' employees
Suppose if you want to change the city of employee praveen above is the command which you can use
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
Suppose if you want to change firstname you can use below command
awk '/praveen/{$1="mandya";print}1' employees
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Better to do with sed command or awk command
Below commands working as per data mentioned in employees. Change the column number as per your data
Otherwise post sample data here
employees
city office name firstname lastname
mysore hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
command :
awk '/praveen/{$1="mandya";print}1' employees
Suppose if you want to change the city of employee praveen above is the command which you can use
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
Suppose if you want to change firstname you can use below command
awk '/praveen/{$1="mandya";print}1' employees
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
add a comment |
up vote
0
down vote
Better to do with sed command or awk command
Below commands working as per data mentioned in employees. Change the column number as per your data
Otherwise post sample data here
employees
city office name firstname lastname
mysore hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
command :
awk '/praveen/{$1="mandya";print}1' employees
Suppose if you want to change the city of employee praveen above is the command which you can use
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
Suppose if you want to change firstname you can use below command
awk '/praveen/{$1="mandya";print}1' employees
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
add a comment |
up vote
0
down vote
up vote
0
down vote
Better to do with sed command or awk command
Below commands working as per data mentioned in employees. Change the column number as per your data
Otherwise post sample data here
employees
city office name firstname lastname
mysore hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
command :
awk '/praveen/{$1="mandya";print}1' employees
Suppose if you want to change the city of employee praveen above is the command which you can use
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
Suppose if you want to change firstname you can use below command
awk '/praveen/{$1="mandya";print}1' employees
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
Better to do with sed command or awk command
Below commands working as per data mentioned in employees. Change the column number as per your data
Otherwise post sample data here
employees
city office name firstname lastname
mysore hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
command :
awk '/praveen/{$1="mandya";print}1' employees
Suppose if you want to change the city of employee praveen above is the command which you can use
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
Suppose if you want to change firstname you can use below command
awk '/praveen/{$1="mandya";print}1' employees
output
city office name firstname lastname
mandya hal praveen kumar yadav
mandya hal praveen kumar yadav
bangalore ngef ajay kumar gowda
mangalore hcl san kumar gowda
answered Nov 16 at 2:40
Praveen Kumar BS
1,076138
1,076138
add a comment |
add a comment |
2
I really hate to be the one to say it but shell scripts are a really bad tool for this. Regardless of what tool you end up using to accomplish this it's probably best to store this data in a database and not some sort of file.
– Jesse_b
Nov 15 at 21:48
Also, it’s not clear what your question is. You don’t say how you’re storing your data — is it one huge file, one small file per employee, multiple files for storing different aspects of the data (e.g., personal data vs. work-related data), or what? While we appreciate seeing what work you’ve already done, the script you’ve posted doesn’t tell us much, except it suggests that you have everything in one file. And you don’t say what your goal is — what do you need to do that you can’t do with
vi "$tumblingfile"
?– Scott
Nov 15 at 22:02
1
You could have each employee be represented by a directory whose name is the employee ID and have each attribute (name, location, salary) be a separate file. (I used this structure for a computer asset database.) If you have constraints on the structure of the file, please edit your question. If this is homework/quiz/exercise (CSCI3331 sounds like a university class), please edit the question to include the complete assignment.
– Mark Plotnick
Nov 15 at 22:02
CSCI3331 is my directory .... tumblingfile is my file name ... and "employees" is where all the employees information is stored inside my directory. my fields are $number , $lname, $city, $state, $zip, $annualsalary . I need help creating a shell script using vi editor to update a specific field of my choosing.
– Christina Tumbling
Nov 15 at 22:17
1
Please do not add information in comments; instead please edit your question to include the extra details. Speaking of details, your question is nigh-impossible to answer without knowing the specifications of how the 'employee' data are stored. SQLite? Flat file? CSV? Fixed-width table? Excel file run through
gzip
? An FLAC file containing a recording of the file being transferred through XMODEM at 9600 baud?– DopeGhoti
Nov 15 at 22:33