- <path to script> or /bin/bash <path to script> or <scriptname> (add script to $PATH environment variable and call as normal command)
- child script is executed in a new shell, changes in child script does not affect parent script
- can be executed asynchronously through background command - <path to script> &
- same as no. 1 but executes child script on background - source <path to script> or . <path to script>
- child script is executed in a current shell
- context is same as parent script (vars and functions of child script becomes visible on parent script)
- exit call in child script will also exit the parent script - exec <path to script>
- terminates the current shell and executes on a new shell
Showing posts with label Command Line. Show all posts
Showing posts with label Command Line. Show all posts
Friday, April 29, 2016
How to call a shell script from another shell script
Note: Make sure to add #!/bin/bash to the first line of the script and make it executable through chmod 700 <path to script>.
Wednesday, April 27, 2016
How to create Bash Script on Mac
- Create the bash script file.
Sample: File myscript.sh#!/bin/bash #”hash-bang" or “she-bang" indicating that this script is to be interpreted and run by the bash shell echo hello world #prints “hello world”
- Change the file permission to make it an executable. Open the terminal, navigate to the location of the file and type the following command:
chmod 700 myscript.sh
See this link for more info on chmod: http://www.thinkplexx.com/learn/article/unix/command/chmod-permissions-flags-explained-600-0600-700-777-100-etc - Run the script. Type the following in the terminal:
./myscript.sh
Sunday, January 27, 2013
Windows and Unix common commands
Windows | Unix | Description |
---|---|---|
attrib | change(clear or set) the attribute of the file | |
cd | pwd | print current working directory |
cd <dir> | cd <dir> | change directory |
cls | clear | clear screen |
cmd | Starts a new instance of the Windows command interpreter | |
copy | cp | copy cp /mySrc . |
date, time | date | print current date and/or time |
del | rm | delete |
deltree | rm - r | recursively delete entire directory tree |
dir | ls | list files and directories ls attributes: -a Include hidden fiels (beginning with .) -l long format -s sort by time modified -r reverse sort |
doskey /h | history | print history |
edit | vi etc. | create new file, show edit window common vi commands: /<text> - search forward n - next occurrence ?<text> - search backward n - previous occurrence :set number - show line number :q | :quit | :q! - quit |
exit | exit Ctrl-D | exit |
find | finds files/folders or string in files Ex. dir c:\ /s /b | find "CPU" - display the file names on drive C that contain the string "CPU" find . -name "foo*" | |
find | grep | search grep -n 'UnknownServiceException' */*/*/server.log grep -rni "string" * .* grep -E "a|b" r = recursive i.e, search subdirectories within the current directory n = to print the line numbers to stdout i = case insensitive search .* = hidden files/directory -E = extended regex (i.e., may use | for or) |
help | man | help/manual displays all available commands & how to use them |
ipconfig /all | ipconfig -a | print network details |
mkdir | mkdir | create new folder/directory |
move | mv | move file or folder |
rmdir | rmdir | remove folder/directory |
set | env | set environment variable |
set Path | echo $PATH | print value of environment var PATH |
start | starting/opening a command/program List of commands for Windows XP, Vista and Windows 7: http://ss64.com/nt/run.html Ex. subst notepad start /d "C:\Program Files (x86)\Notepad++" notepad++.exe -> start the executable and close the command prompt that called it | |
subst | substituting path subst R: D:\temp\temp | |
type | cat | display contents of a file, concatenate files or create a new file Ex. cat > 1.txt This is the first line. - creates a simple text file. ^D mrks the end of file. cat 1.txt - display contents of 1.txt cat 1.txt 2.txt > 3.txt - concatenate 1.txt and 2.txt ans save it in 3.txt |
tree | find ., ls -R | print directory structure |
less | display the contents of a text file on console | |
ln | make link Types: 1. Hard link (default) - Points to a file through inode number. If the original file's name is changed, hard link still points to same file. 2. Symbolic link (ln -s) - Points to a file through name. If the original file's name is changed, symbolic link still points to the original name and does not point anymore to the original file. If the original file's content is changed, symbolic link still points to the same file. ln -s myFolder myShortcut - create ln -sfn myFolder2 myShortcut - update -f = force -n = treat LINK_NAME as a normal file if it is a symbolic link to a directory, else LINK_NAME will be treated as symbolic link and will not effectively remove link to previous target and point to new target | |
printenv | print environment variables | |
tar | archive/extract tar -xvf sample.tar.gz |
PATH
Windows | Unix | Description |
---|---|---|
\ | / | Directory separator, e.g. C:\user\docs\sample.txt |
/ | - | Switch, e.g. dir /w |
[drive letter:]\ or \\[server name]\[volume]\ | / | Root directory |
. | . | Current directory |
.. | .. | Parent directory |
~ | Home directory - $HOME var in UNIX, which usually is /home/username | |
C:\user\docs\sample.txt docs\sample.txt A:pic.jpg \\server01\user\docs\sample.txt | //home/user/docs/Letter.txt
. /inthisdir ../../greatgrandparent ~/.rcinfotd> | Sample paths |
Source:
https://en.wikipedia.org/wiki/Path_(computing)
Wednesday, February 11, 2009
NYAOS (NYACUS,NYADOS,NYAOS-II)
- Nihongo Yet Another Open Shell
- an enhanced commandline shell for Windows,DOS,OS/2
- advantages include filename autocomplete, built-in color, history, etc.
- support and downloads: http://nyaos.org/
1) Download and unzip
2) create env.bat with:
set MAVEN_HOME=S:\commons\apache-maven-2.0.10
set ANT_HOME=S:\commons\apache-ant-1.7.0
set JAVA_HOME=R:\commons\bea\jrockit_150_15
set path=%JAVA_HOME%\bin\;%MAVEN_HOME%\bin;%ANT_HOME%\bin;%PATH%;S:\commons\scripts;D:\Program Files\Rational\clearcase\ClearCase\bin;s:\commons\firefox
mvn -version
3) use nyacus as your cmd with the env properties by creating mycmd.bat with:
nyacus -r env.bat (means that you are loading the script file env.bat instead of _nya)
4) can start other apps by creating start command like eclipse.bat:
set path=R:\commons\bea\jrockit_150_15\bin\;%PATH%;
cmd /C start R:\commons\eclipse -data R:\bel\workspace\workspace33 -vmargs -Xms40m -Xmx512m -XX:MaxPermSize=256m
5) launch mycmd.bat
6) start other apps by calling filename of .cmd
- an enhanced commandline shell for Windows,DOS,OS/2
- advantages include filename autocomplete, built-in color, history, etc.
- support and downloads: http://nyaos.org/
1) Download and unzip
2) create env.bat with:
set MAVEN_HOME=S:\commons\apache-maven-2.0.10
set ANT_HOME=S:\commons\apache-ant-1.7.0
set JAVA_HOME=R:\commons\bea\jrockit_150_15
set path=%JAVA_HOME%\bin\;%MAVEN_HOME%\bin;%ANT_HOME%\bin;%PATH%;S:\commons\scripts;D:\Program Files\Rational\clearcase\ClearCase\bin;s:\commons\firefox
mvn -version
3) use nyacus as your cmd with the env properties by creating mycmd.bat with:
nyacus -r env.bat (means that you are loading the script file env.bat instead of _nya)
4) can start other apps by creating start command like eclipse.bat:
set path=R:\commons\bea\jrockit_150_15\bin\;%PATH%;
cmd /C start R:\commons\eclipse -data R:\bel\workspace\workspace33 -vmargs -Xms40m -Xmx512m -XX:MaxPermSize=256m
5) launch mycmd.bat
6) start other apps by calling filename of .cmd
Subscribe to:
Posts (Atom)