0% found this document useful (0 votes)
19 views

1.a.basic Linux Command

Basic Linux commands

Uploaded by

vinaymarbe40
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

1.a.basic Linux Command

Basic Linux commands

Uploaded by

vinaymarbe40
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

a)

Aim :-
Study of Basic Linux Commands: echo, ls, read, cat, touch, test, loops, arithmetic
comparison, conditional loops, grep, sed.

Objective:
The objective of a practical studying basic Linux commands and related concepts such as
loops, arithmetic comparisons, and conditional statements includes:
Understanding Command-Line Operations: Gain proficiency in executing fundamental Linux
commands like echo, ls, read, cat, touch, test, grep, and sed to manipulate files, display
content, and search text.
Exploring Shell Scripting: Learn to create scripts incorporating loops and conditional
statements (if, while, for) to automate tasks and perform operations based on conditions.
Mastering Text Processing: Develop skills in using grep and sed for efficient text search and
manipulation within files or output streams.

Theory:-

echo
echo "Hello, world!"

Displays text or variables on the terminal.

ls
ls -l # Long listing format

ls -a # Include hidden files

Lists directory contents.

read
echo "Enter your name: "
read name

echo "Hello, $name!"

Reads input from the user.

cat
cat file.txt

Concatenates and displays the content of files.

touch
touch newfile.txt

Creates an empty file or updates the access and modification times of a file.

test
if test -f /path/to/file; then

echo "File exists."

Fi

To check if a file exists, you can use:

Loop
Iterates over a list of items or based on a condition.
# For loop

for i in {1..5}; do

echo "Number: $i"

done

# While loop

counter=0

while [ $counter -lt 5 ]; do

echo "Count: $counter"

((counter++))

done
Arithmetic Operator
result=$((5 + 3))

echo $result # This will output 8

Conditinal Loop

counter=1

# This loop will run as long as the counter is less than or equal to 5

while [ $counter -le 5 ]

do

echo "Iteration: $counter"

((counter++)) # Increment the counter

done

echo "Loop finished!"

grep
grep "pattern" file.txt

Searches for patterns in text.

Conclusion :- Hence we learned….

You might also like