Week 06: Pipes and Redirection
Redirection – Sending output of process to a file
What we learned previously Pipes – Sending output of process to another process
:Linux Basic Commands
date – print system date and time
cd – change directory
ls – list the directory contents
man – manual page
touch – update file timestamp / create a new file
rm – remove files
mkdir – make directory
rmdir – remove directory
cat – concatenate files
cp – copy files
mv – move / rename files
sort – sorting file content
pwd – present working directory
head – output first part of file
tail – output last part of file
Week 06:
mkdir : Case 1
Scenario: First, create ProjectX directory under / directory, then create
SourceCode Directory inside ProjectX Directory, and create two subdirectories
under SourceCode Directory. Directory structure is as under
ProjectX/SourceCode/Python
ProjectX/SourceCode/Javascript
This will be done using single command along with {} sign.
Task: Verify Directory Creation Using Tree
Week 06:
touch: Case 2
Scenario: Create Multiple Files at Once
Task: Create multiple files under directory (/ProjectX/SourceCode/Python) —
file1.txt,file2.txt, and file3.txt. Create multiple files under directory
(/ProjectX/SourceCode/Javascript) — file4.txt and file5.txt.
This will be done in single line command execution with {} and | sign.
Task: Verify files creation Using Tree
Week 06:
cat: Case 3
Scenario: Merge Multiple Files into One
Task: First put “Hello” text in ProjectX/SourceCode/Python/file1.txt, and put
“World” text in ProjectX/SourceCode/Python/file2.txt. Append file2.txt data in
file1.txt
Task: Verify file contents
Task: Print file contents with line numbers
• Introduction to Vim Text Editor
• Vim (Vi IMproved) is a powerful text editor used in Unix-based systems, enhancing the original Vi editor with features like syntax
highlighting, multi-level undo, and plugin support. Vim is known for its efficiency and customization, making it a favorite among
developers and system administrators.
• Modes in Vim
Week 06:
• Vim operates in different modes:
VIM Text Processing Tools in Linux
• Normal Mode: Default mode for navigation and text manipulation.
• Insert Mode: Used for inserting or modifying text (i, a, o).
• Visual Mode: Enables text selection (v, V, Ctrl + V).
• Command Mode: Executes commands like saving and searching (:).
• Basic Vim Commands
• vim filename – Open or create a file.
• i – Enter Insert mode.
• Esc – Return to Normal mode.
• :w – Save the file.
• :q – Quit Vim.
• :wq – Save and quit.
• :q! – Quit without saving.
• dd – Delete a line.
• yy – Copy a line.
• p – Paste text.
• /word – Search for a word.
• u – Undo last change.
Week 06 :
Installing C Language in Linux
This package is called gcc (GNU Compiler Collection)
Week 06:
Installing C Language in Linux
RUN the following command to install C language in Linux
# yum install gcc
Verify the C language installation:
# gcc –-version
Or
# gcc –v
Week 06:
Installing C Language in Linux
RUN the following command to install C language in Linux
# yum install gcc
Verify the C language installation:
# gcc –-version
Or
# gcc –v
Week 06:
Task: Write simple C language in vi text editor, compile and run it
>>> Compile Syntax I
# gcc <filename.c>
>>> RUN C language Program
# ./a.out
>>> Compile Syntax II
# gcc <filename.c> -o <outputfilename>
./outputfilename