Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Download SC290 Gitub Repositorysetpkgs -a git git clone https://github.com/accre/SC290.git
This will create a new directory called SC290, with a subdirectory called bash. See the file make_dirs.sh inside this subdirectory.
You can also see the repository from a web browser: https://github.com/accre/SC290 More examples will be uploaded throughout the semester, to update your local repository, type (from the SC290 directory):
git pull
File Permissions✦All files / directories have one user (or owner - nikki in this example) and one group (guest) associated with them
✦There are three sets (user, group, other) of three permissions (read, write, execute)
✦Only the owner may change the owner, group, or the permissions
Read, Write, Execute
Read Write Execute
FilesYou can look at the file contents
You can modify the file contents
You can run the program
DirectoriesYou can ls the
directory
You can create and delete files
You can cd to the directory
Changing Permissions✦ chmod (change mode) ✦alphabetic method - add or take away (r)ead, (w)rite, or e(x)ecute for the (u)ser, (g)roup, and / or (o)ther
✦ numeric method - read = 4, write = 2, execute = 1; total up what you want for the user, group, and other
Running a Script as a CommandTake the script you wrote last time, and make it executable
chmod +x script_name.sh To run the script as a command, provide the path to the file
absolute path: /home/vuid/script_name.sh relative path: ../example/relative/path/script_name.sh if script is in current working directory: ./script_name.sh
Why does this work? Next time we’ll discuss how to execute this script from any arbitrary directory without having to provide the path
The script will effectively become like any other Unix command (e.g. ls, cat, echo) Any idea why this doesn’t work right now?
Pattern Matching
✦ * - matches zero or more instances of any character ✦ ? - matches one instance of any character ✦ [abc] - matches any one character within the brackets; “a”, “b”, or “c” in this example
✦ [0-9] - matches any one character within the range defined within the brackets
✦ [A-z] - matches all letters, plus most punctuation characters, because this is an ASCII range (use “[A-Za-z]” instead to match only letters
Pattern Matching Examples
Aliases
✦bash syntax - alias rm=”rm -i” ✦ tcsh syntax - alias rm ‘rm -i’ ✦Now when you type rm, the shell will automatically replace it with rm -i
✦alias ll=”ls -la” ✦alias mroe=more ✦alias cdmydir=”cd /some/big/long/path/that/is/hard/to/remember/much/less/type”
Shell Variables✦Many variables are set for you
✦Two types of variables: environment and local
✦ local variables are visible only to the current shell
✦environment variables are also visible to child shells and processes
✦env shows environment variables
Defining Shell Variables✦my_var=some_value - bash syntax for creating a local variable
✦export my_var - makes my_var an environment variable ✦export my_var=some_value - creates an environment variable in one step
✦To print an environment variable, use echo $my_var
Shell Initialization Files✦Any aliases or variables you define on the command line are only in effect for the duration of that session
✦To make them permanent, simply add them to your .bashrc file
A Few Useful Filters
✦wc - word count ✦grep - (g)et (r)egular (e)xpression and (p)rint (i.e. pattern matching)
✦ sort - sort alphabetically or numerically ✦uniq - filter duplicate lines ✦ cut - cut specific fields or columns ✦ sed - stream editor (i.e. search and replace) ✦awk - programming language for quick processing
Pipes and Filters
✦Pipes take the output of one command and make it the input to another command
✦Analogous to plumbing pipes ✦ Filters are commands which can accept input from another command and also produce output
✦Syntax is command | filter_command ✦Multiple pipes and filters can be strung together on one command line - command | filter_command1 | filter_command2 | filter_command3
Compressing / Archiving Files
✦ If you have a Windows client, use zip / unzip ✦Example: zip mydata.zip ./mydatadir/* ✦Then use scp to copy the data to your client and unzip it there: unzip mydata.zip
✦ If you have a Linux or Mac client, use tar and gzip ✦Example: tar cvf mydata.tar ./mydatadir/*; gzip mydata.tar
✦Then use scp to copy the data to your client and uncompress / untar it there: gzip -d mydata.tar.gz; tar xvf mydata.tar
Getting Help from ACCRE✦ ACCRE website FAQ and Getting Started pages: http://
www.accre.vanderbilt.edu/support ✦ ACCRE helpdesk: http://www.accre.vanderbilt.edu/support/contact/
submit_RT.php ✦Tickets default to non-rush queue, which is for tickets about an issue which only impacts you and / or can wait until the next business day.
✦Rush tickets are for issues which would impact the cluster as a whole.
✦Rush queue pages ACCRE personnel (we normally only have staff on site during normal business hours), so please think before opening up a rush ticket at 3 AM!
✦ If you open a rush ticket - day or night - please plan to be available to work with ACCRE personnel to resolve the issue.
✦Once the issue (rush or non-rush) is resolved we would appreciate it if you would let us know.
Getting Help from ACCRE
Getting Help from ACCRE✦accre-forum mailing list ✦ACCRE office hours: open a help desk ticket and mention that you would like to work personally with one of us in the office. The person most able to help you with your specific issue will contact you to schedule a date and time for your visit.