Assuming you’re using bash #!/bin/bash current_dir=$(pwd) script_dir=$(dirname $0) echo $current_dir echo $script_dir This script, when ran, should print the directory that you’re in, and then the directory the script is in, for example, when calling it from / (the script is in /home/mez/), it outputs / /home/mez Remember, when assigning variables from the output of Full Article…
Viewing 1 to 3 of 3 items
display how many files that user accessed
All of these commands can be used inside of your scripts and can make for a very powerful toolset for developing programs in unix. For an example of using these commands in a script, let’s write a script that uses our current data file. The script will get all users that are in the file Full Article…
how I can execute without mentioning bash before shell script name
To run the script by just executing the script name you need three things. Check if all are there. 1) script should have executable permissions. 2) directory where script exists should be in PATH environment variable. 3) You should have execute permissions on all the directories comprising of path to script. your script must have Full Article…