code
stringlengths
1
1.96M
language
stringclasses
1 value
#!/bin/sh foo="Hello World" echo $foo unset foo echo $foo
Shell
#!/bin/sh while [ "$1" != "" ]; do echo "$1" shift done exit 0
Shell
#!/bin/sh for x in 1 2 3 do echo before $x continue 1 echo after $x done exit 0
Shell
#!/bin/sh cat <<!FUNKY! hello this is a here document !FUNKY!
Shell
#!/bin/sh # Ask some questions and collect the answer gdialog --title "Questionnaire" --msgbox "Welcome to my simple survey" 9 18 gdialog --title "Confirm" --yesno "Are you willing to take part?" 9 18 if [ $? != 0 ]; then gdialog --infobox "Thank you anyway" 5 20 sleep 2 gdialog --clear exit 0 fi...
Shell
#!/bin/sh salutation="Hello" echo $salutation echo "The program $0 is now running" echo "The second parameter was $2" echo "The first parameter was $1" echo "The parameter list was $*" echo "The user's home directory is $HOME" echo "Please enter a new greeting" read salutation echo $salutation echo "The script is no...
Shell
#!/bin/sh for foo in bar fud 43 do echo $foo done exit 0
Shell
#!/bin/sh x=0 while [ "$x" -ne 10 ]; do echo $x x=$(($x+1)) done exit 0
Shell
#!/bin/sh echo "Is it morning? Please answer yes or no" read timeofday case "$timeofday" in "yes") echo "Good Morning";; "no" ) echo "Good Afternoon";; "y" ) echo "Good Morning";; "n" ) echo "Good Afternoon";; * ) echo "Sorry, answer not recognised";; esac exit 0
Shell
#!/bin/sh version=latest PATH=/usr/local/new_bin:/usr/bin:/bin:. PS1=" latest version> "
Shell
#!/bin/sh echo -n "Is it morning? Please answer yes or no: " read timeofday if [ "$timeofday" = "yes" ] then echo "Good morning" elif [ "$timeofday" = "no" ]; then echo "Good afternoon" else echo "Sorry, $timeofday not recognized. Enter yes or no" exit 1 fi exit 0
Shell
#!/bin/sh # first # This file looks through all the files in the current # directory for the string POSIX, and then prints the name of # those files to the standard output. for file in * do if grep -q POSIX $file then echo $file fi done exit 0
Shell
#!/bin/sh touch file_one rm -f file_two if [ -f file_one ] && echo "hello" && [ -f file_two ] && echo "there" then echo "in if" else echo "in else" fi exit 0
Shell
#!/bin/sh foo() { echo "Function foo is executing" } echo "script starting" foo echo "script ended" exit 0
Shell
#!/bin/sh rm -rf fred* echo > fred1 echo > fred2 mkdir fred3 echo > fred4 for file in fred* do if [ -d "$file" ]; then echo "skipping directory $file" continue fi echo file is $file done rm -rf fred* exit 0
Shell
#!/bin/sh ed textfile <<!FunkyStuff! 3 d .,\$s/is/was/ w q !FunkyStuff! exit 0
Shell
#!/bin/sh sample_text="global variable" foo() { local sample_text="local variable" echo "Function foo is executing" echo $sample_text } echo "script starting" echo $sample_text foo echo "script ended" echo $sample_text exit 0
Shell
#!/bin/sh rm -rf fred* echo > fred1 echo > fred2 mkdir fred3 echo > fred4 for file in fred* do if [ -d "$file" ]; then break; fi done echo first directory fred was $file rm -rf fred* exit 0
Shell
#!/bin/sh trap 'rm -f /tmp/my_tmp_file_$$' INT echo creating file /tmp/my_tmp_file_$$ date > /tmp/my_tmp_file_$$ echo "Press interrupt (Ctrl-C) to interrupt...." while [ -f /tmp/my_tmp_file_$$ ]; do echo File exists sleep 1 done echo The file no longer exists trap INT echo creating file /tmp/my_tmp_file_$$ d...
Shell
#!/bin/sh rm -f fred if [ -f fred ]; then : else echo file fred does not exist fi exit 0
Shell
#!/bin/sh # Ask some questions and collect the answer dialog --title "Questionnaire" --msgbox "Welcome to my simple survey" 9 18 dialog --title "Confirm" --yesno "Are you willing to take part?" 9 18 if [ $? != 0 ]; then dialog --infobox "Thank you anyway" 5 20 sleep 2 dialog --clear exit 0 fi di...
Shell
#!/bin/sh echo "Is it morning? Please answer yes or no" read timeofday if [ "$timeofday" = "yes" ] then echo "Good morning" elif [ "$timeofday" = "no" ]; then echo "Good afternoon" else echo "Sorry, $timeofday not recognized. Enter yes or no" exit 1 fi exit 0
Shell
#!/bin/sh for file in $(ls f*); do echo $file done exit 0
Shell
#!/bin/sh cat <<!FUNKY! hello this is a here document !FUNKY!
Shell
#!/bin/sh salutation="Hello" echo $salutation echo "The program $0 is now running" echo "The second parameter was $2" echo "The first parameter was $1" echo "The parameter list was $*" echo "The user's home directory is $HOME" echo "Please enter a new greeting" read salutation echo $salutation echo "The script is no...
Shell
#!/bin/sh echo "Is it morning? Please answer yes or no" read timeofday if [ "$timeofday" = "yes" ] then echo "Good morning" elif [ "$timeofday" = "no" ]; then echo "Good afternoon" else echo "Sorry, $timeofday not recognized. Enter yes or no" exit 1 fi exit 0
Shell
#!/bin/sh rm -rf fred* echo > fred1 echo > fred2 mkdir fred3 echo > fred4 for file in fred* do if [ -d "$file" ]; then echo "skipping directory $file" continue fi echo file is $file done rm -rf fred* exit 0
Shell
#!/bin/sh for x in 1 2 3 do echo before $x continue 1 echo after $x done exit 0
Shell
#!/bin/sh foo() { echo "Function foo is executing" } echo "script starting" foo echo "script ended" exit 0
Shell
#!/bin/sh echo "Is it morning? Please answer yes or no" read timeofday case "$timeofday" in yes | y | Yes | YES ) echo "Good Morning" echo "Up bright and early this morning?" ;; [nN]* ) echo "Good Afternoon" ;; * ) echo "Sorry, an...
Shell
#!/bin/sh version=latest PATH=/usr/local/new_bin:/usr/bin:/bin:. PS1=" latest version> "
Shell
#!/bin/sh rm -rf fred* echo > fred1 echo > fred2 mkdir fred3 echo > fred4 for file in fred* do if [ -d "$file" ]; then break; fi done echo first directory fred was $file rm -rf fred* exit 0
Shell
#!/bin/sh touch file_one rm -f file_two if [ -f file_one ] && echo "hello" && [ -f file_two ] && echo "there" then echo "in if" else echo "in else" fi exit 0
Shell
#!/bin/sh echo "Enter password" read trythis while [ "$trythis" != "secret" ]; do echo "Sorry, try again" read trythis done exit 0
Shell
#!/bin/sh x=0 while [ "$x" -ne 10 ]; do echo $x x=$(($x+1)) done exit 0
Shell
#!/bin/sh for file in $(ls f*); do echo $file done exit 0
Shell
#!/bin/sh trap 'rm -f /tmp/my_tmp_file_$$' INT echo creating file /tmp/my_tmp_file_$$ date > /tmp/my_tmp_file_$$ echo "Press interrupt (Ctrl-C) to interrupt...." while [ -f /tmp/my_tmp_file_$$ ]; do echo File exists sleep 1 done echo The file no longer exists trap INT echo creating file /tmp/my_tmp_file_$$ d...
Shell
#!/bin/sh echo -n "Is it morning? Please answer yes or no: " read timeofday if [ "$timeofday" = "yes" ] then echo "Good morning" elif [ "$timeofday" = "no" ]; then echo "Good afternoon" else echo "Sorry, $timeofday not recognized. Enter yes or no" exit 1 fi exit 0
Shell
#!/bin/sh echo "Is it morning? Please answer yes or no" read timeofday if [ $timeofday = "yes" ]; then echo "Good morning" else echo "Good afternoon" fi exit 0
Shell
#!/bin/sh rm -f file_one if [ -f file_one ] || echo "hello" || echo "there" then echo "in if" else echo "in else" fi exit 0
Shell
#!/bin/sh while [ "$1" != "" ]; do echo "$1" shift done exit 0
Shell
#!/bin/sh echo The date is $(date) set $(date) echo The month is $2 exit 0
Shell
#!/bin/sh yes_or_no() { echo "Is your name $* ?" while true do echo -n "Enter yes or no: " read x case "$x" in y | yes ) return 0;; n | no ) return 1;; * ) echo "Answer yes or no" esac done } echo "Original parameters are $*" if yes_or_no "$1" then echo "Hi $1, nice...
Shell
#!/bin/sh if [ -f /bin/bash ] then echo "file /bin/bash exists" fi if [ -d /bin/bash ] then echo "/bin/bash is a directory" else echo "/bin/bash is NOT a directory" fi
Shell
#!/bin/sh foo="Hello World" echo $foo unset foo echo $foo
Shell
#!/bin/sh module="shortprint" device="shortprint" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}
Shell
#!/bin/sh module="shortprint" device="shortprint" mode="666" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use a pathname, as newer modutils don't l...
Shell
#!/bin/sh module="shortprint" device="shortprint" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}
Shell
#!/bin/sh module="shortprint" device="shortprint" mode="666" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use a pathname, as newer modutils don't l...
Shell
#!/bin/sh module="scullc" device="scullc" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/sh module="scullc" device="scullc" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/sh module="scullc" device="scullc" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="scullc" device="scullc" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="simple" device="simple" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}[rn]
Shell
#!/bin/sh module="simple" device="simple" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use a pathname, as newer modutils don't look in . ...
Shell
#!/bin/sh module="simple" device="simple" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}[rn]
Shell
#!/bin/sh module="simple" device="simple" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use a pathname, as newer modutils don't look in . ...
Shell
#!/bin/sh function make_minors { let part=1 while (($part < $minors)); do let minor=$part+$2 mknod $1$part b $major $minor let part=$part+1 done } # FIXME: This isn't handling minors (partitions) at all. module="sbull" device="sbull" mode="664" chardevice="sbullr" minors=16 # Group: since distributio...
Shell
#!/bin/sh module="sbull" device="sbull" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}[a-d]* /dev/${device}
Shell
#!/bin/sh function make_minors { let part=1 while (($part < $minors)); do let minor=$part+$2 mknod $1$part b $major $minor let part=$part+1 done } # FIXME: This isn't handling minors (partitions) at all. module="sbull" device="sbull" mode="664" chardevice="sbullr" minors=16 # Group: since distributio...
Shell
#!/bin/sh module="sbull" device="sbull" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}[a-d]* /dev/${device}
Shell
#!/bin/sh module="scull" device="scull" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device} /dev/${device}[0-3] rm -f /dev/${device}priv rm -f /dev/${device}pipe /dev/${device}pipe[0-3] rm -f /dev/${device}single rm -f /dev/${device}uid rm -f /dev/${de...
Shell
#!/bin/sh # $Id: scull_load,v 1.4 2004/11/03 06:19:49 rubini Exp $ module="scull" device="scull" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep -q '^staff:' /etc/group; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use ...
Shell
#!/bin/bash # Sample init script for the a driver module <rubini@linux.it> DEVICE="scull" SECTION="misc" # The list of filenames and minor numbers: $PREFIX is prefixed to all names PREFIX="scull" FILES=" 0 0 1 1 2 2 3 3 priv 16 pipe0 32 pipe1 33 pipe2 34 pipe3 35 ...
Shell
#!/bin/sh # $Id: scull_load,v 1.4 2004/11/03 06:19:49 rubini Exp $ module="scull" device="scull" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep -q '^staff:' /etc/group; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use ...
Shell
#!/bin/bash # Sample init script for the a driver module <rubini@linux.it> DEVICE="scull" SECTION="misc" # The list of filenames and minor numbers: $PREFIX is prefixed to all names PREFIX="scull" FILES=" 0 0 1 1 2 2 3 3 priv 16 pipe0 32 pipe1 33 pipe2 34 pipe3 35 ...
Shell
#!/bin/sh module="scull" device="scull" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device} /dev/${device}[0-3] rm -f /dev/${device}priv rm -f /dev/${device}pipe /dev/${device}pipe[0-3] rm -f /dev/${device}single rm -f /dev/${device}uid rm -f /dev/${de...
Shell
#!/bin/sh /sbin/ifconfig sn0 down /sbin/ifconfig sn1 down /sbin/rmmod snull
Shell
#!/bin/sh export PATH=/sbin:/bin # Use a pathname, as new modutils don't look in the current dir by default insmod ./snull.ko $* ifconfig sn0 local0 ifconfig sn1 local1
Shell
#!/bin/sh /sbin/ifconfig sn0 down /sbin/ifconfig sn1 down /sbin/rmmod snull
Shell
#!/bin/sh export PATH=/sbin:/bin # Use a pathname, as new modutils don't look in the current dir by default insmod ./snull.ko $* ifconfig sn0 local0 ifconfig sn1 local1
Shell
#!/bin/sh module="scullv" device="scullv" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="scullv" device="scullv" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/sh module="scullv" device="scullv" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="scullv" device="scullv" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/sh module="short" device="short" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use a pathname, as newer modutils don't look in . b...
Shell
#!/bin/sh module="short" device="short" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}[0-7] /dev/${device}[0-7][ps] \ /dev/${device}int /dev/${device}print
Shell
#!/bin/sh module="short" device="short" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # Remove stale nodes rm -f /dev/${device}[0-7] /dev/${device}[0-7][ps] \ /dev/${device}int /dev/${device}print
Shell
#!/bin/sh module="short" device="short" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # invoke insmod with all arguments we got # and use a pathname, as newer modutils don't look in . b...
Shell
#!/bin/sh module="scullp" device="scullp" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/sh module="scullp" device="scullp" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="scullp" device="scullp" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/sh module="scullp" device="scullp" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="sculld" device="sculld" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/sh module="sculld" device="sculld" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="sculld" device="sculld" mode="664" # Group: since distributions do it differently, look for wheel or use staff if grep '^staff:' /etc/group > /dev/null; then group="staff" else group="wheel" fi # remove stale nodes rm -f /dev/${device}? # invoke insmod with all arguments we got # and use a...
Shell
#!/bin/sh module="sculld" device="sculld" # invoke rmmod with all arguments we got /sbin/rmmod $module $* || exit 1 # remove nodes rm -f /dev/${device}[0-3] /dev/${device} exit 0
Shell
#!/bin/bash # # $Id: gdbline,v 1.1 2004/08/02 16:27:55 corbet Exp $ # # gdbline module image # # Outputs an add-symbol-file line suitable for pasting into gdb to examine # a loaded module. # cd /sys/module/$1/sections echo -n add-symbol-file $2 `/bin/cat .text` for section in .[a-z]* *; do if [ $section != ".text"...
Shell
#!/bin/bash # # $Id: gdbline,v 1.1 2004/08/02 16:27:55 corbet Exp $ # # gdbline module image # # Outputs an add-symbol-file line suitable for pasting into gdb to examine # a loaded module. # cd /sys/module/$1/sections echo -n add-symbol-file $2 `/bin/cat .text` for section in .[a-z]* *; do if [ $section != ".text"...
Shell
#!/bin/sh # script2: a real program with variables, input, # and control flow BOOK=$HOME/phonebook.data echo find what name in phonebook read NAME if grep $NAME $BOOK > /tmp/pb.tmp then echo Entries for $NAME cat /tmp/pb.tmp else echo No entries for $NAME fi rm /tmp/pb.tmp
Shell
#!/bin/sh # script3 - shows how an environment variable is passed to commands # TZ is timezone, affect things like date, and ls -l # echo "The time in Boston is" TZ=EST5EDT export TZ # add TZ to the environment date # date uses the value in TZ echo "The time in Chicago is" TZ=CST6CDT dat...
Shell
#!/bin/sh # script3 - shows how an environment variable is passed to commands # TZ is timezone, affect things like date, and ls -l # echo "The time in Boston is" TZ=EST5EDT export TZ # add TZ to the environment date # date uses the value in TZ echo "The time in Chicago is" TZ=CST6CDT dat...
Shell
#!/bin/sh # script2: a real program with variables, input, # and control flow BOOK=$HOME/phonebook.data echo find what name in phonebook read NAME if grep $NAME $BOOK > /tmp/pb.tmp then echo Entries for $NAME cat /tmp/pb.tmp else echo No entries for $NAME fi rm /tmp/pb.tmp
Shell
#!/bin/sh # # atm.sh - a wrapper for two programs # while true do do_a_transaction # run a program if play_again # run our program then continue # if "y" loop back fi break # if "n" break done
Shell
#!/bin/sh # # atm.sh - a wrapper for two programs # while true do do_a_transaction # run a program if play_again # run our program then continue # if "y" loop back fi break # if "n" break done
Shell
#!/bin/sh # # watch.sh - a simple version of the watch utility, written in sh # who | sort > prev # get initial user list while true # true is a program: exit(0); do sleep 30 # wait a while who | sort > current # get current user list echo "Logged out:" # print header comm -23 prev current # and result...
Shell
#!/bin/sh # # watch.sh - a simple version of the watch utility, written in sh # who | sort > prev # get initial user list while true # true is a program: exit(0); do sleep 30 # wait a while who | sort > current # get current user list echo "Logged out:" # print header comm -23 prev current # and result...
Shell
#!/bin/sh # # watch.sh - a simple version of the watch utility, written in sh # who | cut -d" " -f1 | sort -u > prev # get current user list while true # true is a program: exit(0); do sleep 30 # wait a while who | cut -d" " -f1 | sort -u > current # get current user list echo "Logged out:" # print heade...
Shell
#!/bin/sh # # watch.sh - a simple version of the watch utility, written in sh # who | cut -d" " -f1 | sort -u > prev # get current user list while true # true is a program: exit(0); do sleep 30 # wait a while who | cut -d" " -f1 | sort -u > current # get current user list echo "Logged out:" # print heade...
Shell
#----------------- # make_release.sh # Version: $Id: make_release.sh,v 1.1 2008/07/07 13:57:13 minahito Exp $ #----------------- # This shell script removes unneeded directories and files from file tree that you checked out, # and makes the file tree to release. # if [ -e ../html/xoops.css ]; then find .. -t...
Shell