0% found this document useful (0 votes)
79 views9 pages

1 Practical No 1 Basic Command and Directory

The document provides examples of Linux commands for listing, searching, copying, moving and renaming files and directories. It demonstrates how to list files with specific patterns or characters in their names. It also shows how to create directories, copy files between directories, remove and rename files, and view file and directory listings.

Uploaded by

Tuba
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)
79 views9 pages

1 Practical No 1 Basic Command and Directory

The document provides examples of Linux commands for listing, searching, copying, moving and renaming files and directories. It demonstrates how to list files with specific patterns or characters in their names. It also shows how to create directories, copy files between directories, remove and rename files, and view file and directory listings.

Uploaded by

Tuba
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/ 9

Practical no 1

Basic Commands.

1.List all filenames


Code:

$cd

cd/bin

bin $ ls

output:

2.List all filenames with 2 character, 3 character.


Code:

bin $ ls ?? ???

output
3.List all filenames with 2 and 4 characters at same file
Code:

bin $ ls ?? ????

output:

4.list all filenames starting with vowel


Code:

bin $ ls [aeiou]*

output:

5.list all filenames with exactly 3 characters in which the second character is vowel
Code:

bin $ ls ?[aeiou]?

output:
6.list all filenames with last character as a or b orc orc
Code:

bin $ ls * [abcd]

output:

7.list all filenames starting with character ‘b’.


Code:
bin $ ls b*
output:

8.list all 4 character filenames whose first character is ‘b’ and third character is ‘c’.
Code:

bin $ ls b? c?

output:

9.list all filenames whose first character is ‘m’ or ‘r’ or or is in the range c to f or v
to z.

Code:

bin $ ls [mrc –fv- z]*

output:

10.list all filenames whose first character is anything other than an alphabet
in the range d to m.
Code:

bin $ ls [!d-m]*

output:
11.construct a command to display the total number of files with exactly 3
character in their filename
Code:

bin $ ls ??? !wc-l

output:

12.list all filenames with one screen at a time


Code:

bin $ ls !more

output:
Directory Command:
Code:

User37@kcmit-desktop ~ $ mkdir fy5 fy6

User37@kcmit-desktop ~ $ cd fy5

User37@kcmit-desktop ~/fy5 $ touch f5 f6

User37@kcmit-desktop ~/fy5 $ ls

f5 f6

user37@kcmit-desktop ~/fy5 $ cd

user37@kcmit-desktop ~ $ cd fy6

user37@kcmit-desktop ~/fy6 $ touch f7 f8

user37@kcmit-desktop ~/fy6 $ ls

f7 f8

user37@kcmit-desktop ~/fy6 $ cd

user37@kcmit-desktop ~ $ cd fy5

user37@kcmit-desktop ~/fy5 $ cp f5 fy6

user37@kcmit-desktop ~/fy5 $ cp f6 fy6

user37@kcmit-desktop ~/fy5 $ cd

user37@kcmit-desktop ~ $ cd fy6

user37@kcmit-desktop ~/fy6 $ ls

f7 f8

user37@kcmit-desktop ~/fy6 $ cp f7 fy6

user37@kcmit-desktop ~/fy6 $ cp f8 fy6


user37@kcmit-desktop ~/fy6 $ cd

user37@kcmit-desktop ~ $ cd fy5

user37@kcmit-desktop ~/fy5 $ ls

f5 f6 fy6

user37@kcmit-desktop ~/fy5 $ rm f5 f6

user37@kcmit-desktop ~/fy5 $ ls

fy6

user37@kcmit-desktop ~/fy5 $ cd fy6

-bash: cd: fy6: Not a directory

User37@kcmit-desktop ~/fy5 $ touch f6

User37@kcmit-desktop ~/fy5 $ ls

f6 fy6

user37@kcmit-desktop ~/fy5 $ mv f7 newf7

mv: cannot stat `f7': No such file or direct

user37@kcmit-desktop ~/fy5 $ mkdir f7 f8

user37@kcmit-desktop ~/fy5 $ cd fy6

-bash: cd: fy6: Not a directory

User37@kcmit-desktop ~/fy5 $ mv f7 newf7

User37@kcmit-desktop ~/fy5 $ mv f8 newf8

User37@kcmit-desktop ~/fy5 $ mv f6 newf6

User37@kcmit-desktop ~/fy5 $ ls

fy6 newf6 newf7 newf8

user37@kcmit-desktop ~/fy5 $ mv newf7 fy5

user37@kcmit-desktop ~/fy5 $ mv newf8 fy5


user37@kcmit-desktop ~/fy5 $ ls

fy5 fy6 newf6

user37@kcmit-desktop ~/fy5 $ ^C

-bash: :s^C: substitution failed

User37@kcmit-desktop ~/fy5 $

output:

You might also like