Cat : Display file contents ,Creating Files and Concatinating files.
cat [options] [filenames] [-] [filenames]
cat filename
cat options filename
Using cat creating file:
$ cat >cmd_usage.txt
cat command for file oriented operations.
cp command for copy files or directories.
$ cat cmd_usage.txt
cat command for file oriented operations.
cp command for copy files or directories.
Append text to existing file.
$ cat >>cmd_usage.txt
ls command to list out file and directory with its attributes.
$ cat cmd_usage.txt
cat command for file oriented operations.
cp command for copy files or directories.
ls command to list out file and directory with its attributes.
Note: If file already exist, Don't try to create file it will overwrite the text in existing file.
Concatenating Files:
cat file1 file2 file3 > file4
Cat options
-A, --show-all Equivalent to -vET.
-b, --number-nonblank Number non-empty output lines. This option overrides -n.
-e Equivalent to -vE.
-E, --show-ends Display "$" at end of each line.
-n, --number Number all output lines.
-s, --squeeze-blank Suppress repeated empty output lines.
-t Equivalent to -vT.
-T, --show-tabs Display TAB characters as ^I.
-v, --show-nonprinting Use ^ and M- notation, except for LFD and TAB.
--help Display a help message, and exit.
--version Output version information, and exit.
CP - COPY
cp command in Linux/Unix
cp is a Linux shell command to copy files and directories.
cp syntax
cp options
cp examples
cp code generator
cp command syntax
Copy from source to dest
$ cp [options] source dest
cp command options
cp command main options:
option description
cp -a archive files
cp -f force copy by removing the destination file if needed
cp -i interactive - ask before overwrite
cp -l link files instead of copy
cp -L follow symbolic links
cp -n no file overwrite
cp -R recursive copy (including hidden files)
cp -u update - copy when source is newer than dest
cp -v verbose - print informative messages
cp command examples
Copy single file main.c to destination directory bak:
$ cp main.c bak
Copy 2 files main.c and def.h to destination absolute path directory /home/usr/rapid/ :
$ cp main.c def.h /home/usr/rapid/
Copy all C files in current directory to subdirectory bak :
$ cp *.c bak
Copy directory src to absolute path directory /home/usr/rapid/ :
$ cp src /home/usr/rapid/
Copy all files and directories in dev recursively to subdirectory bak:
$ cp -R dev bak
Force file copy:
$ cp -f test.c bak
Interactive prompt before file overwrite:
$ cp -i test.c bak
cp: overwrite 'bak/test.c'? y
Update all files in current directory - copy only newer files to destination directory bak:
$ cp -u * bak
MV-Move
mv command syntax
$ mv [options] source dest
mv command options
mv command main options:
option description
mv -f force move by overwriting destination file without prompt
mv -i interactive prompt before overwrite
mv -u update - move when source is newer than destination
mv -v verbose - print source and destination files
man mv help manual
mv command examples
Move main.c def.h files to /home/usr/rapid/ directory:
$ mv main.c def.h /home/usr/rapid/
Move all C files in current directory to subdirectory bak :
$ mv *.c bak
Move all files in subdirectory bak to current directory :
$ mv bak/* .
Rename file main.c to main.bak:
$ mv main.c main.bak
Rename directory bak to bak2:
$ mv bak bak2
Update - move when main.c is newer:
$ mv -u main.c bak
$
Move main.c and prompt before overwrite bak/main.c:
$ mv -v main.c bak
'bak/main.c' -> 'bak/main.c'
mv command syntax
$ mv [options] source dest
mv command options
mv command main options:
option description
mv -f force move by overwriting destination file without prompt
mv -i interactive prompt before overwrite
mv -u update - move when source is newer than destination
mv -v verbose - print source and destination files
man mv help manual
mv command examples
Move main.c def.h files to /home/usr/rapid/ directory:
$ mv main.c def.h /home/usr/rapid/
Move all C files in current directory to subdirectory bak :
$ mv *.c bak
Move all files in subdirectory bak to current directory :
$ mv bak/* .
Rename file main.c to main.bak:
$ mv main.c main.bak
Rename directory bak to bak2:
$ mv bak bak2
Update - move when main.c is newer:
$ mv -u main.c bak
$
Move main.c and prompt before overwrite bak/main.c:
$ mv -v main.c bak
'bak/main.c' -> 'bak/main.c'
$
Pipeine: |
Using pipeline first command output will be input to second command
cat | more
Semicolon: ;
Multiple commands we ran with semicolon.
pwd ; cat filename ; ls
More and Less: paging out
Used with pipeline
More command to scroll one side
Less command to scroll both side
cat filename | more
cat filename | less
History:
History command to see all old commands.
cat [options] [filenames] [-] [filenames]
cat filename
cat options filename
Using cat creating file:
$ cat >cmd_usage.txt
cat command for file oriented operations.
cp command for copy files or directories.
$ cat cmd_usage.txt
cat command for file oriented operations.
cp command for copy files or directories.
Append text to existing file.
$ cat >>cmd_usage.txt
ls command to list out file and directory with its attributes.
$ cat cmd_usage.txt
cat command for file oriented operations.
cp command for copy files or directories.
ls command to list out file and directory with its attributes.
Note: If file already exist, Don't try to create file it will overwrite the text in existing file.
Concatenating Files:
cat file1 file2 file3 > file4
Cat options
-A, --show-all Equivalent to -vET.
-b, --number-nonblank Number non-empty output lines. This option overrides -n.
-e Equivalent to -vE.
-E, --show-ends Display "$" at end of each line.
-n, --number Number all output lines.
-s, --squeeze-blank Suppress repeated empty output lines.
-t Equivalent to -vT.
-T, --show-tabs Display TAB characters as ^I.
-v, --show-nonprinting Use ^ and M- notation, except for LFD and TAB.
--help Display a help message, and exit.
--version Output version information, and exit.
CP - COPY
cp command in Linux/Unix
cp is a Linux shell command to copy files and directories.
cp syntax
cp options
cp examples
cp code generator
cp command syntax
Copy from source to dest
$ cp [options] source dest
cp command options
cp command main options:
option description
cp -a archive files
cp -f force copy by removing the destination file if needed
cp -i interactive - ask before overwrite
cp -l link files instead of copy
cp -L follow symbolic links
cp -n no file overwrite
cp -R recursive copy (including hidden files)
cp -u update - copy when source is newer than dest
cp -v verbose - print informative messages
cp command examples
Copy single file main.c to destination directory bak:
$ cp main.c bak
Copy 2 files main.c and def.h to destination absolute path directory /home/usr/rapid/ :
$ cp main.c def.h /home/usr/rapid/
Copy all C files in current directory to subdirectory bak :
$ cp *.c bak
Copy directory src to absolute path directory /home/usr/rapid/ :
$ cp src /home/usr/rapid/
Copy all files and directories in dev recursively to subdirectory bak:
$ cp -R dev bak
Force file copy:
$ cp -f test.c bak
Interactive prompt before file overwrite:
$ cp -i test.c bak
cp: overwrite 'bak/test.c'? y
Update all files in current directory - copy only newer files to destination directory bak:
$ cp -u * bak
MV-Move
mv command syntax
$ mv [options] source dest
mv command options
mv command main options:
option description
mv -f force move by overwriting destination file without prompt
mv -i interactive prompt before overwrite
mv -u update - move when source is newer than destination
mv -v verbose - print source and destination files
man mv help manual
mv command examples
Move main.c def.h files to /home/usr/rapid/ directory:
$ mv main.c def.h /home/usr/rapid/
Move all C files in current directory to subdirectory bak :
$ mv *.c bak
Move all files in subdirectory bak to current directory :
$ mv bak/* .
Rename file main.c to main.bak:
$ mv main.c main.bak
Rename directory bak to bak2:
$ mv bak bak2
Update - move when main.c is newer:
$ mv -u main.c bak
$
Move main.c and prompt before overwrite bak/main.c:
$ mv -v main.c bak
'bak/main.c' -> 'bak/main.c'
mv command syntax
$ mv [options] source dest
mv command options
mv command main options:
option description
mv -f force move by overwriting destination file without prompt
mv -i interactive prompt before overwrite
mv -u update - move when source is newer than destination
mv -v verbose - print source and destination files
man mv help manual
mv command examples
Move main.c def.h files to /home/usr/rapid/ directory:
$ mv main.c def.h /home/usr/rapid/
Move all C files in current directory to subdirectory bak :
$ mv *.c bak
Move all files in subdirectory bak to current directory :
$ mv bak/* .
Rename file main.c to main.bak:
$ mv main.c main.bak
Rename directory bak to bak2:
$ mv bak bak2
Update - move when main.c is newer:
$ mv -u main.c bak
$
Move main.c and prompt before overwrite bak/main.c:
$ mv -v main.c bak
'bak/main.c' -> 'bak/main.c'
$
Pipeine: |
Using pipeline first command output will be input to second command
cat | more
Semicolon: ;
Multiple commands we ran with semicolon.
pwd ; cat filename ; ls
More and Less: paging out
Used with pipeline
More command to scroll one side
Less command to scroll both side
cat filename | more
cat filename | less
History:
History command to see all old commands.
No comments:
Post a Comment