0% found this document useful (0 votes)
46 views5 pages

Asignment 3 (UNIX)

This assignment covers basic UNIX commands. Students were asked to complete tasks like listing files in a folder and subfolders, searching for a string within files, renaming files with prefixes or suffixes, counting lines in text files, replacing substrings in file names, and viewing commonly used commands from command history. The answers provided solutions to these tasks using UNIX commands like ls, grep, for loops, and processing the output of history.

Uploaded by

Sanjarbek
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)
46 views5 pages

Asignment 3 (UNIX)

This assignment covers basic UNIX commands. Students were asked to complete tasks like listing files in a folder and subfolders, searching for a string within files, renaming files with prefixes or suffixes, counting lines in text files, replacing substrings in file names, and viewing commonly used commands from command history. The answers provided solutions to these tasks using UNIX commands like ls, grep, for loops, and processing the output of history.

Uploaded by

Sanjarbek
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/ 5

Program Name BSc IT V

Assignment - 3 (Faculty Name) – Prof Pranav Shrivastava

Course Name: UOSSP Assignment No.: - 3 Date: 29.11.2021

Student’s Name: Alex Brown

Brief Description:
This assignment covers the basic UNIX command line interface
commands

Assignment Objective

To make the student learn about basic UNIX commands

Module Covered:

Module -2 – BASH Commands

Students’ Learning Outcomes Achieved:

Student were able to learn and implement basic UNIX commands


 
 
Question 1: Write a command to list all the files inside a folder i.e. if there is a folder inside a
folder then it should list all files inside the sub-folder which is inside the folder to be listed.
 

Question 2: Search all the files which contains a particular string, say “include” within a folder.
 
 
Question 3: Rename all the files within a folder with suffix “Unix_” i.e., suppose a folder has
two files a.txt and b.pdf than they both should be renamed from a single command to Unix_a.txt
and Unix_b.pdf
 
Question 4: Rename all files within a folder with the first word of their content (remember all the
files should be text files. For example, if a.txt contains “Unix is an OS” in its first line then a.txt
should be renamed to Unix.txt
 
Question 5 : Suppose you have a C project in a folder called “project”, it contains .c and .h files,
it also contains some other .txt files and .pdf files. Write a Linux command that will count the
number of lines of your text files. That means total line count of every file. (Remember you have
to count the lines in .txt files only)
 
Question 6 : Rename all files which contain the sub-string 'foo', replacing it with 'bar' within a
given folder.
 
Question 7 : Show the most commonly used commands from “history”. [hint: remember the
history command, use cut, and sort it.
 

 
 Answers.

1). The ls command, by default, displays all information in alphabetical order by file
name. If the command is used by a root user, the -A flag is used by default, which lists
except all dot (.) and dot dot (..). Use the ls -a command to display all entries for files,
even those that start with a dot (.).

The output can be formatted in the following ways:

Using the -l flag, list one entry per line.

By using the -C or -x flags, you can list entries in multiple columns. When output is to a
tty, the -C flag is used as the default format.

Specify the -m flag to list entries in a comma-separated series.The $COLUMNS


environment variable is used by the ls command to calculate the number of character
positions in the output line. The command reads the term info file if this variable is not
set.

2). We can use the –grep command to find a string in a file, and I'll show you how to do
it in my terminal:
3). I'm using a for loop to rename all of the files in a specific directory.

The command is as follows:

4.)
5).

6).

7.)

You might also like