Question

In: Computer Science

1. Give a command using find to search from the root directory the file program.f and...

1. Give a command using find to search from the root directory the file program.f and redirect any errors to the file myerrors.txt

2. Give a command for finding files having the letters index as the beginning of the file name and located in your home directory (provide the absolute path)

3. Give a command for finding within a directory called /mp3collection, only those mp3 files that have a size less than 5000 Kilobytes (< 5MB).

4. Give a commmand that searches for those files that are present in the directory /home/david and its subdirectories which end in .c and which have been accessed in the last 10 minutes.

5. Give a command that searches within the directory /mp3-collection for files that have their names beginning with ’Metallica’ and whose size is greater than 10000 kilobytes (> 10 MB).

6. Give a command that searches in the same directory as above case but only for files that are greater than 10MB, but they should not have ’Metallica’ as the starting of their filenames.

7. Explain what the following commands do. What is the major difference between their outputs? a) chmod -R 755 . b) chmod -R 755 *

8. Explain the output of the following command:

pr -t -n -d -o 10 group12

9. Study the cut command and describe what is its function, provide some examples including options like -c, and -f.

10. What is the output of the following command?

sort -t: -k3,3 -n /etc/group

Solutions

Expert Solution

ANSWER 7: In the event that you wish to alter your Files/Directories ownership you can utilize the chmod command.  We use chmod command in order to change the authorizations of a document in Unix. In this order we can pass the record authorizations as a three-digit number.

In this number 755, first digit 7 is the authorizations given to owner, second digit 5 is the authorization of group and third digit 5 is the authorizations of all others.

Likewise the numbers 7 and 5 are produced using keeping rules:

4 = read consent

2 = compose consent

1 = execute consent

So 7 = 4 + 2 + 1 = Read + Write + Execute consent

5 = 4 + 1 = Read + Execute consent (Consent means permissions)

Part a)

In our above example chmod -R 755 means, the owner has read, write and execute consents. Group and others have read and execute authorizations only.

Also the -R means changing records and directories recursively.

Therefore, the command "chmod - R 755 myfiles" means "Recursively (- R) Change the authorizations of the directory myfiles, and all files and folders it contains, to mode 755 where User can read, write, and execute; group members and different clients can read and execute, however can't write."

Part b)

Linux enables you to utilize wild cards, shown with an indicator * to carry out an activity on a gathering of documents:

For e.g - chmod 755 *.cgi .

Here, we've advised Linux to set permissions on all records in the directory that end with .cgi

ANSWER 8: On Unix-like OS, the pr command arranges a file to make it look better when printed. pr paginates FILE(s) for printing.

  • -t option is used when the page length is less than or equal to 10.
  • -n option is used for providing line numbering based on the number of digits specified by the variable width.
  • -d option is used for producing double-spaced output.
  • -o option indents each line by the quantity of character positions indicated by the Offset variable. The complete number of character positions per line is the whole of the width and counterbalance. The default Offset worth is 0.
  • group10 is the file name.

ANSWER 9: The cut order separates a given number of characters or sections from a document. For cutting a specific number of sections it is essential to determine the delimiter. A delimiter determines how the sections are isolated in a book document.

syntax : cut [options] [filename]

- c (section): To cut by character utilize the - c alternative. This chooses the characters given to the - c choice. This can be a rundown of numbers isolated comma or a scope of numbers isolated by hyphen(- ). Tabs and deletes are treated as a character. It is important to determine rundown of character numbers else it gives blunder with this alternative.

e.g. =>  $ cut -c 5-10 file1 : This command will extract characters 5 to 10 from each line.

- f (field): - c alternative is helpful for fixed-length lines. Most unix records doesn't have fixed-length lines. To remove the valuable data you have to cut by fields as opposed to segments. Rundown of the fields number determined must be isolated by comma. Extents are not depicted with - f alternative. cut uses tab as a default field delimiter yet can likewise work with other delimiter by utilizing - d choice. Note: Space isn't considered as delimiter in UNIX.

e.g. => For delimiter separated fields, the -d option is used. The default delimiter is the tab character.

$ cut -d “,” -f 2,6 file1 : This command will extract the second and sixth field from each line, using the ‘,’ character as the delimiter.

ANSWER 10:

SORT command is utilized to sort a document, masterminding the records in a specific request. As a matter of course, the sort direction sorts document accepting the substance are ASCII. Utilizing alternatives in sort direction, it can likewise be utilized to sort numerically.

- k Option : Unix gives the component of arranging a table based on any segment number by utilizing - k alternative.

Utilize the - k alternative to sort on a specific segment. the "- k3 " to sort on the third section.

- n Option : To sort a document numerically utilized – n alternative. - n choice is likewise predefined in unix as the above alternatives seem to be. This alternative is utilized to sort the document with numeric information present inside.

/etc/group is the file path.


Related Solutions

In Linux Terminal 1. Give a command using find to search from the root directory the...
In Linux Terminal 1. Give a command using find to search from the root directory the file program.f and redirect any errors to the file myerrors.txt 2. Give a command for finding files having the letters index as the beginning of the file name and located in your home directory (provide the absolute path) 3. Give a command for finding within a directory called /mp3collection, only those mp3 files that have a size less than 5000 Kilobytes (< 5MB). 4....
a) you can see a program for using bisection search to find the square root of...
a) you can see a program for using bisection search to find the square root of x: x = 25 epsilon = 0.01 low = 0.0 high = max(1.0, x) guess = (low + high) / 2 numberofguesses = 1 while abs(guess ** 2 - x) > epsilon : print('low =', low, 'high = ', high, 'guess = ', guess) if guess** 2 > x : # the guess is too high, so move high down to guess high =...
1. What command is used to change the current working directory at the command line?
1. What command is used to change the current working directory at the command line?
PYTHON - You are given a data.csv file in the /root/customers/ directory containing information about your...
PYTHON - You are given a data.csv file in the /root/customers/ directory containing information about your customers. It has the following columns: ID,NAME,CITY,COUNTRY,CPERSON,EMPLCNT,CONTRCNT,CONTRCOST where ID: Unique id of the customer NAME: Official customer company name CITY: Location city name COUNTRY: Location country name CPERSON: Email of the customer company contact person EMPLCNT: Customer company employees number CONTRCNT: Number of contracts signed with the customer CONTRCOST: Total amount of money paid by customer (float in format dollars.cents) Read and analyze the...
Using one Unix command, how to go to my home directory using tilde, ~. Using one...
Using one Unix command, how to go to my home directory using tilde, ~. Using one Unix command, how to go to your home directory using tilde, ~. Make sure you are in your home directory. Using one Unix command, how to go to your hw4 directory inside your hw directory, inside your it244directory using a relative pathname. Using one Unix command, how to go to my home directory using an absolute pathname. Using one Unix command, how to go...
Create a file named work.sh in your hw5 directory. Give this file read and write permission...
Create a file named work.sh in your hw5 directory. Give this file read and write permission (no execute permissions) for you alone. No other account should have any access privileges to this file. Change the permissions on the work.sh file so you have read and write permissions. Give everybody else, including the group, read permissions only. Give yourself read, write and execute permissions to the file work.sh. Give everyone else, including the group, execute permissions only. Create a directory named...
Linux Directories, File Properties, and the File System in C Your version of find command Try...
Linux Directories, File Properties, and the File System in C Your version of find command Try running the find command in the shell and observe the output. Try it in different folders to make sure you understand what it prints out. $ find Write your version of the find command and add comments.
1. At the command prompt, use the where command to locate the where.exe file. Copy and...
1. At the command prompt, use the where command to locate the where.exe file. Copy and paste the full path and filename for the where.exe file into the space provided below. 2. At the command prompt, enter the following command and press enter. find "free beer" "c:\Program Files (x86)\Notepad++\*.txt" This command searches for the string "free beer" in all .TXT files in the Notepad++ program folder. According to the output of the find command, which of the files listed below...
Which command do you use to find the process that’s holding a file open? 1. w...
Which command do you use to find the process that’s holding a file open? 1. w 2. ps 3. top 4. fuser
To find a positive root for , write a MATLAB script file that uses Bisection method....
To find a positive root for , write a MATLAB script file that uses Bisection method. Choose any initial value that is needed. Use absolute relative approximate error to be less than 0.01. Your code should report the number of iteration and the value of x.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT