0% found this document useful (0 votes)
4 views3 pages

Commands

Uploaded by

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

Commands

Uploaded by

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

$ cat file1 | tr [a-z] [A-Z]

$ cat file1 | tr [:lower:] [:upper:]

translate white-space characters to tabs.

$ echo "Welcome To Information Technology" | tr [:space:] "\t"

translate braces into parenthesis.

$ cat file1
{WELCOME TO}
Information Technology

$ tr "{}" "()" <file1>newfile.txt

$ cat state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh

cut -b 1,2,3 state.txt


cut -b 1-3,5-7 state.txt

$ cat capital
Itanagar
Dispur
Hyderabad
Patna
Raipur

$ paste number state capital


1 Arunachal Pradesh Itanagar
2 Assam Dispur
3 Andhra Pradesh Hyderabad
4 Bihar Patna
5 Chhattisgrah Raipur

Only one character is specified


$ paste -d "|" number state capital
1|Arunachal Pradesh|Itanagar
2|Assam|Dispur
3|Andhra Pradesh|Hyderabad
4|Bihar|Patna
5|Chhattisgrah|Raipur

More than one character is specified


$ paste -d "|," number state capital
1|Arunachal Pradesh,Itanagar
2|Assam,Dispur
3|Andhra Pradesh,Hyderabad
4|Bihar,Patna
5|Chhattisgrah,Raipur

cat > geekfile.txt

unix is great os. unix was developed in Bell labs.


learn operating system.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
grep -i "UNix" geekfile.txt

Displaying the Count of Number of Matches Using


grep
grep -c "unix" geekfile.txt
grep -l "unix" *
Checking for the Whole Words in a File Using grep
grep -w "unix" geekfile.txt

To file File Permission

#!/bin/bash

echo -n "Enter file name: "


read -r file
# checks if file has write permission or not
[ -w "${file}" ] && W="Write = yes" || W="Write = No"

# checks if file has execute permission or not


[ -x "${file}" ] && X="Execute = yes" || X="Execute = No"

# checks if the file has read permission


[ -r "${file}" ] && R="Read = yes" || R="Read = No"
echo "$file permissions"
echo "$W"
echo "$R"
echo "$X"

To check existence of file

target_file="/root/hello.sh"
if test -f "$target_file"
then
echo "$target_file exist."
else
echo "$target_file does not exist."
fi

To Add two numbers

#!/bin/bash

# Program name: "add.sh"


# Shell script program to add two numbers.

#num1=30
#num2=40

echo "Enter value of first number: "


read num1

echo " Enter value of second number: "


read num2

add=`expr $num1 + $num2`

echo "Sum is: $add"

You might also like