bang or shebang line is path to interpreter
---------------------------------------------------------
#! /usr/bin/sh
#Shebang line
date
hostname
#!/usr/bin/env perl
#!/usr/bin/env python
#Metacharacters
^ $ .; [ ] { } - ? * + ( ) | \
All others are literals
---------------------------------------------------------
#Newline
\n
#Multi-line statement
total_items = item1 + \
item2 + \
item3
Commenting style vary from single line to multi-line (block comments); also vary for different languages.
For C, C++, Java, SQL
// Line comment for C, C++, Java, SQL, php
--Single line comment for SQL
/* block comment for C, C++, C# Java, SQL, php */
-----------------------------------
For Shell, Python, Perl, php
# Line comment for shell, python, perl, php, ruby
''' block comment for python'''
: <<‘END’
block comment for shell/Linux/Bash
‘END’
<<COMMENT1
block comment for shell/Linux/Bash
COMMENT1
: '
block comment for shell/Linux/Bash
'
=begin comment
block comment for perl
=cut
=begin
block comment for ruby
=end
-----------------------------------
For MATLAB
% Line comment
; symbol at the end of statement suppresses display of the output.
-----------------------------------
For Lisp
; Line comment
-----------------------------------
For HTML
<!- Comment ->
-----------------------------------
For Haskell
-- Line comment
{-comment line1
comment line2 -}
-----------------------------------
echo $PATH
PATH=$PATH:$HOME/bin
Here PATH is modified to add the directory $HOME/bin to the end of the list.(Parameter expansion)
PATH=~/bin:$PATH:.
---------------------------------------------------------
#! /usr/bin/sh
#Shebang line
date
hostname
#!/usr/bin/env perl
#!/usr/bin/env python
##################################################
To execute .sh script
sh script.sh
To direct the standard output (monitor display) of the code into a file, the following one-liner can be used. Here the regular execution command for the .sh file has been piped to tee command. The file data_file is generated. Its pretty useful.
sh script.sh |& tee output_file
Show top 100 lines only
sh script.sh | head -100
---------------------------------------------------------Show top 100 lines only
sh script.sh | head -100
#Metacharacters
^ $ .; [ ] { } - ? * + ( ) | \
All others are literals
---------------------------------------------------------
#Newline
\n
#Multi-line statement
total_items = item1 + \
item2 + \
item3
Commenting style vary from single line to multi-line (block comments); also vary for different languages.
For C, C++, Java, SQL
// Line comment for C, C++, Java, SQL, php
--Single line comment for SQL
/* block comment for C, C++, C# Java, SQL, php */
-----------------------------------
For Shell, Python, Perl, php
# Line comment for shell, python, perl, php, ruby
''' block comment for python'''
: <<‘END’
block comment for shell/Linux/Bash
‘END’
<<COMMENT1
block comment for shell/Linux/Bash
COMMENT1
: '
block comment for shell/Linux/Bash
'
=begin comment
block comment for perl
=cut
=begin
block comment for ruby
=end
-----------------------------------
For MATLAB
% Line comment
; symbol at the end of statement suppresses display of the output.
-----------------------------------
For Lisp
; Line comment
-----------------------------------
For HTML
<!- Comment ->
-----------------------------------
For Haskell
-- Line comment
{-comment line1
comment line2 -}
-----------------------------------
echo $PATH
PATH=$PATH:$HOME/bin
Here PATH is modified to add the directory $HOME/bin to the end of the list.(Parameter expansion)
PATH=~/bin:$PATH:.
No comments:
Post a Comment