User Tools

Site Tools


opus:fall2012:eolson1:unixpart2

unix Keyword 2

wildcards

Definition

wildcards are used in unix and other operating systems when searching for files or directory’s. some of the most common wildcards are the * and ?. The asterisk is used to represent any number of unknown characters. For example if you typed in file* you may receive a number of files beginning with file… file1.txt, file2.txt, fileboy.txt, fileoctopus.txt. Note that the .txt has nothing to do with it it is just a file name extension. The ? make on the other hand only represents one unknown character so if you typed in file? you will only receive file names such as file.txt, file1.txt, file2.txt but now files with more than one extra character after the name file.

References

unix Keyword 2 Phase 2

shabang

Definition

A shabang is this: #! The shabang is used to read the following test on the first line after it to determine what interpreter the user would like to… use. Some example of interpreters (Taken directly from http://en.wikipedia.org/wiki/Shebang_(Unix):

  • #!/bin/bash – Execute the file using sh, the Bourne shell, or a compatible shell
  • #!/bin/csh – Execute the file using csh, the C shell, or a compatible shell
  • #!/usr/bin/perl -T – Execute using Perl with the option for taint checks
  • #!/usr/bin/php – Execute the file using the PHP command line interpreter
  • #!/usr/bin/python -0 – Execute using Python with optimizations to code
  • #!/usr/bin/ruby – Execute using Ruby

References

Demonstration

The #!/bin/bash makes the script use the bash interpreter.

  1 #!/bin/bash
  2 #
  3 #script 3
  4 #
  5 #
  6
  7 value=`bc <<< "$RANDOM"`
  8 num=`bc <<< "$RANDOM"`
  9
 10 While [ $num -ne $RANDOM ] ;
 11 do
 12
 13 echo -n "guess a value: "
 14 echo "$num"
 15 echo "Nope $num is not equal to $RANDOM"
 16
 17 done
 18
 19
 20 echo "YAY!!!!! IT WORKED!"
 21
 22
 23 exit 0
opus/fall2012/eolson1/unixpart2.txt · Last modified: 2012/10/31 13:42 by eolson1