The following unix shell scripts commands for handling files like creating file, copying file, moving file and listing files.
CREATING FILE IN UNIX
$ touch file1 -> creates file 'file1'(if not exist) or changes time stamp(if already exist). This command will create zero bytes file with name file1
$ vi file1 -> 'vi file1' is VI Editor command for creating file. If you give vi file1, file1 will create and it will open for edit.
USAGE OF UNIX CAT COMMANDS
$ cat file1 -> display contents of 'file1'. It will just display the content of specified file(file1) in non edit mode.
$ cat < file1 -> display contents of 'file1'. It will also behave like above command
$ cat > file1 -> write contents to 'file1'. File will open with edit mode. It will get over write the previous file content
$ cat >> file1 -> append contents to 'file1'. File will open with edit mode. but here we can append over the specified file.
write command " $ cat >> file1" In command line. After editing press CTRL+D to come out.
$ cat file1 file2 -> display contents of 'file1' and file2' one after other
USAGE OF UNIX LS COMMANDS
$ ls -> lists all directories and files in current directory
$ ls d1-> lists all directories and files in target directory
$ ls -a -> lists all including hidden ones
$ ls -r -> lists all in reverse order
$ ls -R -> lists all recursively
$ ls -l -> lists with details ie long list
$ ls -i -> lists with i node value
$ ls -F -> lists all with info on format(directory name with ‘/’ as suffix, executable files with ‘*’ as suffix etc.)
$ ls -l file1 -> lists details of file 'file1'
USAGE OF OTHER FILE HANDLING UNIX COMMANDS
$ file file1 file2 -> displays type of file 'file1' and 'file2'
$ more file1 -> page wise display of 'file1'
to view contents of 'file1' page wise(press space bar), line wise(press enter)
$ echo file1 -> It will also create file with zero bytes.
For any clarification with respect above commands reach me on by comments.
No comments:
Post a Comment