This action might not be possible to undo. Are you sure you want to continue?
It acts as a interface between Hardware and the user.Lets look at the below diagram for more information... UNIX is a Character User Interface (CUI )OS Different types of OS :: CUI GUI Character User Interface Graphical User Interface eg., MS-DOS,UNIX eg., LINUX , WINDOWS , MACINTOSH UNIX File System:: A file is the basic structure used to store information on the UNIX system.The UNIX file system provides a logical method for organizing,storing,retreiving,manipulating and information. A file can store manuscripts and other word processing documents, instructions or programs for the computer itself, an organized database of business information, a bitmap description of a screen image, or any other kind of information stored as sequence of bytes on a computer. With in UNIX, there are three different types of files :: Regular Files Directory Files Special Files Explanation :: Regular Files As a user, the information that you work with will be stored as an ordinary file.Ordinary files/Regualr file aggregates of characters that are treated as a unit by the UNIX system. A Regualr file can contain normal ASCII characters such as text for manuscripts or programs.Ordinary file can be created, changed, or deletedas you wish. Directory Files Directory is a file that holds other files and contain information about the locations and attributes of these other files.For example a directory includes a list of all the files and sub directories that it contains, as well as their addresses, characteristics, file types and other attributes. Basic Commands # system adimistrator prompt $ user working prompt $pwd :: It displays present working directory. (If you login with dwhlabs) /home/dwhlabs
$logname :: It displays the current username.
. #password user1 Enter password :: Retype password :: System Run Levels #init :: To change the system run levels. hidden files $ls -f :: It displays files. Day Month date hour:min:sec standard name year FRI MAY 23 10:50:30 IST 2008 $banner :: It prints a message in large letters. $ls -a :: It displays files and directories including . $date :: It displays the current system date and time. #useradd user1 #password :: To give the password to a particular user terminal. $banner "tecno" Administrator Commands # system adimistrator prompt $ user working prompt #useradd :: To add the user terminals. #init 0 : To shut down the system #init 1or s: To bring the system to single user mode.executable files. and . $ls -x :: It displays width wise $ls | pg :: It displays list of files and directoriews page wise & width wise. #init 6 : Halt and reboot the system to the default run level. symbolic files . diectories. #init 2 : To bring the system multi user mode with no resource shared. ls command options $ls :: This command is used to display list of files and directories. #init 3 : To bring the system multi user mode with resource shared.dwhlabs $clear :: It clears the screen.
^ $ * . $ls -l :: It displays files and directories in long list format.a1 a2 sample\ letter* notes@ \ directory * executable files .wild card $ ls [a-z]ra It displays all files starting with any character between a to z and ends with 'ra'.30 student Different types of files :: .The length of the file must be 3 characters. $ls -i :: It displays files and directories along with inode number.symbolic link file $ls -r ::It displays files and directories in reverse order.$ Description It matches one or more characters It matches any single character It matches any single character in the given list It matches any character in that range It matches any single character except enter key character.(descending order) $ls -R:: Itr displays files and directories recursively. $ ls ?ram It displays all files starting with any character and also the length of the file must be 4 characters.ordinary file d directory file b special block files c special character file l symboliclink file Wild card characters wild card character * ?  . Examples :: * wild card $ ls t* It displays all files starting with 't' character. $ls -t :: It displays files and directories based on date and time of creation.. . ? .  . .-. It displays line which starts with that character It displays line which ends with that character.^. $ ls *s It displays all files ending with 's' $ ls b*k It displays all files starting with b and ending with k ? wild card $ ls t?? It displays all files starting with 't' character and also file length must be 3 characters. Filter Commands $ grep ::Gloabally Search a Regular expression and print it. . . file type permission link uname group sizeinbytes date filename rw-r 1 tec group 560 nov 3 1:30 sample d rwxr-wr 2 tec group 430 mar 7 7.
$grep dwhlabs dwh (It displays all the lines in a file which as dwhlabs pattern/string) Character Pattern eg.$fgrep "unix >c++ >Data Warehouse" stud egrep :: Extended grep This command is used to search for single or multiple patterns and also regular expressions. $grep \< dwhlabs\> dwh (It displays all the line in a file which as a exact word 'dwhlabs') Word Pattern eg. $grep ^UNIX$ language (It displays all the lines in the file which has a single word 'UNIX' ) Line Pattern $grep options $grep -i pattern filename (ignore case sensitive) $grep -c pattern filename (It displays total count of lines) $grep -n pattern filename (It displays along with the line number) $grep -l pattern filename (It displays filename in the current directory) $grep -v pattern filename (It displays unmatched pattern lines) Question ? Q)How to remove blank lines in a file? A)$grep -v "^$" file1>tmp | mv tmp>file1 Explanation :: Piping concept is used to combine more than one cammand. syntax . >patternn " filename eg.. syntax .This command is used to search a particular pattern(single string ) in a file or directory and regualr expression(pattern which uses wild card characters).$grep pattern filename eg. Filter Commands $ cut :: This command is used to retreive the required fields or characters from a file.Here we first identifing the non blank files in file1 and redirecting the result to tmp (temporary file).Now check the file1 result <You will not find any blank lines> fgrep :: This command is used to search multiple strings or one string but not regular expression. $grep "dwhlabs website" dwh .This temporary file is input to the next command. Now we are renaming the tmp into file1. 100 101 Rakesh UNIX Ramani C++ HYD CHE ..character pattern eg..$fgrep "pattern1 >pattern2 >.
102 Prabhu C BAN 103 Jyosh DWH CHE syntax . $uniq -u employee (displays non duplicated lines) eg.' 1-8 employee $ sort :: This command is used to sort the file records in ascending or descending $sort Options $sort -r filename (reverse) $sort -u filename (unique records) $sort -n filename(show the number along sorting) How to sort data in field wise ? syntax. $uniq -d employee ( displays duplicated lines) Question :: Q) How to remove duplicate lines in a file? A) $uniq employee>temp $mv temp employee * _ . $cut -f 0-2 employee (all the fields in the above file) 100 101 102 103 Rakesh UNIX Ramani C++ Prabhu C Jyosh DWH eg.$uniq filename eg. $cut options $cut -f 0-2 employee $cut -c 1-8 employee $cut -d '. $sort -f +1 -2 employee $ uniq :: This command is used to filter the duplicate lines from a file Note :: Always the file must be in sorting order. . $uniq employee $uniq Options eg. $cut -c 1-8 employee (first 8 characters) 100 Rake 101 Rama 102 Prab 103 Jyos Delimeters Default ( Tab ) : . syntax .$sort -f +pos1 -pos2 filename eg.$cut -f 1-3 filename eg.
$ diff :: Compare the two files and shows the difference. $ tail :: Display last 'N' number of files. ============ Shell Scripting Exercise General Write a script to open a given file? Write a script to delete the blank lines from a file? write a script to delete duplicate lines from a file? 1 2 3 if then else 4 Write a script to check the givn number is positive or negative? 5 Write a script to check the given number is even or odd number? 6 Write a script to accept two strings and check the given strings are equal or not? 7 Write a script to delete the given file? 8 Write a script to check the given user is logged in or not? 9 Write a script to check the given type of file? 10 Write a script to open the given file? File watchers / File test commands 11 Write a script to check the given two files are equal or not? case 12 13 Write a script to check the given type of character? Write a script to create the menu creation? . $ wc :: Display word (or character or line ) count for file. $ cmp :: Compare two files andd list where differences occur. $ head :: Display first 'N' number of files. $ sed :: This command is used for editing files from a script or from the command line.Filter Commands $ tr :: Translate the character in string1 from stdin into those in string2 in stdout.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.