I wanted to revise shell scripting to my friend.
Here are the list of commands that we used.
The kernel: agent
The shell: interface between the user and the kernel,
command line interpreter
bash
tcsh
etc
http://unixhelp.ed.ac.uk/shell/oview2.html
(show terminal)
You can scroll up and down with arrow key...
Everything in unix is either file or a process. Thats why no exe/virus.
The directory structure is simple idea. The structure is like an inverted tree.
(how to drag the file into terminal)
http://linux.about.com/od/commands/l/blcmds.htm
ls
ls -a
ls *.mat
ls a?.mat
mkdir testdir
cd testdir
mkdir direc1
cd .. (paraent directory)
cd . (current dir)
pwd (print working directory)
ls testdir (list the contents of testdir)
can use full filename
ls testdir/direc1
cd (go home!)
cp fullpathname of a file
mv fullpathname of a file
rm
clear
whoami
which
%====================== Break Break!
create a test.txt file
cat test.txt (can be used to display the contents)
grep : searches files for specified words or patterns
grep Science science.txt
The grep command is case sensitive; it distinguishes between Science and science.
To ignore upper/lower case distinctions, use the -i option, i.e. type
% grep -i science science.txt
To search for a phrase or pattern, you must enclose it in single quotes (the apostrophe symbol). For example to search for spinning top, type
% grep -i 'spinning top' science.txt
How to check mail from terminal
cat text1.txt text2.txt>text3.txt
Concatenate 1 and 2 into 3
append using >>
mail -s "sending history" dfe @gemail.com < history
s: subject
samething with a pipe
date | mail -s "let's try a pipe" blsdfi@asdfe.com
The result of this operation is that the output of the who command will be sent directly to the input of the mail command, without the intermediate step of storing the data in a file.
man command#name (manual of the command)
kill #processID (mac, I learned)
opendiff file file2
===============
Unzip:
gunzip test.txt.gz
chmod u+rwx filename
To give yourself permission to execute a file that you own:
chmod u+x file1
x: execute
r: read
w: write
Setting access permissions numerically
There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r w x
4 2 1
These values are added together for any one user category:
1 = execute only
2 = write only
3 = write and execute (1+2)
4 = read only
5 = read and execute (4+1)
6 = read and write (4+2)
7 = read and write and execute (4+2+1)
So access permissions can be expressed as three digits. For example:
user group others
chmod 640 file1 rw- r-- ---
chmod 754 file1 rwx r-x r--
chmod 664 file1 rw- rw- r--
history
http://usefulcodes.blogspot.com/search/label/mac
http://usefulcodes.blogspot.com/2011/11/using-imagemagick-shell-command-to-crop.html
http://usefulcodes.blogspot.com/search/label/unix
for statement
http://unixhelp.ed.ac.uk/scrpt/scrpt2.6.2.1.html
http://unixhelp.ed.ac.uk/scrpt/scrpt2.6.3.2.html
making shell script:
save as display.sh
cat display
# This script displays the date, time, username and
# current directory.
echo "Date and time is:"
date
echo
echo "Your username is: `whoami` \n"
echo "Your current directory is: \c"
pwd
========
ftp into another computer
ftp> get image1.jpg
ftp> put asdf.png
ftp> prompt
mput [file]
Uploads multiple files matching [filespec]
bye
vi ~/.bash_profile
==
The kernel: agent
The shell: interface between the user and the kernel,
command line interpreter
bash
tcsh
etc
http://unixhelp.ed.ac.uk/shell/oview2.html
(show terminal)
You can scroll up and down with arrow key...
Everything in unix is either file or a process. Thats why no exe/virus.
The directory structure is simple idea. The structure is like an inverted tree.
(how to drag the file into terminal)
http://linux.about.com/od/commands/l/blcmds.htm
ls
ls -a
ls *.mat
ls a?.mat
mkdir testdir
cd testdir
mkdir direc1
cd .. (paraent directory)
cd . (current dir)
pwd (print working directory)
ls testdir (list the contents of testdir)
can use full filename
ls testdir/direc1
cd (go home!)
cp fullpathname of a file
mv fullpathname of a file
rm
clear
whoami
which
%====================== Break Break!
create a test.txt file
cat test.txt (can be used to display the contents)
grep : searches files for specified words or patterns
grep Science science.txt
The grep command is case sensitive; it distinguishes between Science and science.
To ignore upper/lower case distinctions, use the -i option, i.e. type
% grep -i science science.txt
To search for a phrase or pattern, you must enclose it in single quotes (the apostrophe symbol). For example to search for spinning top, type
% grep -i 'spinning top' science.txt
How to check mail from terminal
cat text1.txt text2.txt>text3.txt
Concatenate 1 and 2 into 3
append using >>
mail -s "sending history" dfe @gemail.com < history
s: subject
samething with a pipe
date | mail -s "let's try a pipe" blsdfi@asdfe.com
The result of this operation is that the output of the who command will be sent directly to the input of the mail command, without the intermediate step of storing the data in a file.
man command#name (manual of the command)
kill #processID (mac, I learned)
opendiff file file2
===============
Unzip:
gunzip test.txt.gz
chmod u+rwx filename
To give yourself permission to execute a file that you own:
chmod u+x file1
x: execute
r: read
w: write
Setting access permissions numerically
There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r w x
4 2 1
These values are added together for any one user category:
1 = execute only
2 = write only
3 = write and execute (1+2)
4 = read only
5 = read and execute (4+1)
6 = read and write (4+2)
7 = read and write and execute (4+2+1)
So access permissions can be expressed as three digits. For example:
user group others
chmod 640 file1 rw- r-- ---
chmod 754 file1 rwx r-x r--
chmod 664 file1 rw- rw- r--
history
http://usefulcodes.blogspot.com/search/label/mac
http://usefulcodes.blogspot.com/2011/11/using-imagemagick-shell-command-to-crop.html
http://usefulcodes.blogspot.com/search/label/unix
for statement
http://unixhelp.ed.ac.uk/scrpt/scrpt2.6.2.1.html
http://unixhelp.ed.ac.uk/scrpt/scrpt2.6.3.2.html
making shell script:
save as display.sh
cat display
# This script displays the date, time, username and
# current directory.
echo "Date and time is:"
date
echo
echo "Your username is: `whoami` \n"
echo "Your current directory is: \c"
pwd
========
ftp into another computer
ftp> get image1.jpg
ftp> put asdf.png
ftp> prompt
mput [file]
Uploads multiple files matching [filespec]
bye
vi ~/.bash_profile
==
No comments:
Post a Comment