Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Shell Scripting Help
Name: Slamo Date: May 13, 2003 at 19:25:33 Pacific OS: Windows Xp Professional CPU/Ram: P4 2.3 GHz 512MB DDR333
Comment:
Hi, can anyone help me, I am doing an assignment and I'm having trouble figuring it out.
First of all. I am using the Bourne shell and I need to display the user of the shell script their Surname followed by their first name. I also have to display the path for their home directory which I have tried doing with:
echo Your home directory is `$home`
but that doesn't seem to work.
If anyone can help it would be greatly appreciated.
It might depend on the shell you're using or the platform you're on. Try $LOGNAME.
0
Response Number 11
Name: Slamo Date: May 18, 2003 at 02:50:42 Pacific
Reply:
Is there any way I can display the user name in the format SURNAME, FIRSTNAME
Sorry, I should of asked that originally.
0
Response Number 12
Name: propyl Date: May 23, 2003 at 16:34:37 Pacific
Reply:
The name of the shell script can be displayed from the script.
SCRIPTNAME="`basename $0`" echo "Name of script is: ${SCRIPTNAME}"
0
Response Number 13
Name: propyl Date: May 23, 2003 at 16:50:23 Pacific
Reply:
Set USERNAME to the LOGNAME you want to process, then ...
cat /etc/passwd|grep \^${USERNAME}: | \ awk -F: '{print $5}' | awk '{print $2,$1}' Inefficient but reliable! The grep starts with "^" and ends with ":" to to stop false matches e.g. smith and smithy. First awk in the pipe is delimited ":". Second awk is delimited space. Enjoy.
Summary: I need help on writing 2 shell scripts: 1) Write a shell script, to be called `keep', that will take any number of file names as arguments. It should remove all files from the current directory...
Summary: Please help me on two shell scripts: 1. the script simulates the ls -l command but prints only three columns of our choice. 2. the script makes a file out of the information in the etc/passwd. file u...
Summary: I want to write bourne shell script called clean.Clean should move all files in a specified directory that has not been modified after the specified date, to a directory called .junk. the command shou...