Find the answer to your Linux question:
Results 1 to 2 of 2
Hi! Everyone, How can i write the following two problems in bash script, can anyone help. Thank you. 1. Write a short script that tells you whether the permissions for ...
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    1

    Two shell script problem, can anyone help?

    Hi! Everyone, How can i write the following two problems in bash script, can anyone help. Thank you.

    1. Write a short script that tells you whether the permissions for two files, whose names are given as arguments to the script, are identical. If the permissions for the two files are identical, output the common permission field. Otherwise, output each filename followed by its permission field. (Hint: Try using the cut utility.)

    I know if i use this script in the following, i can get permission for the file count.txt, but i am not sure how to write this entire problem, can anyone help, thank you.

    ls -l count.txt | cut -c2-10

    2. Write a script that takes a colon-separated list of items and outputs the items, one per line, to standard output (without the colons).

  2. #2
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by jason7361 View Post
    Hi! Everyone, How can i write the following two problems in bash script, can anyone help. Thank you.

    1. Write a short script that tells you whether the permissions for two files, whose names are given as arguments to the script, are identical. If the permissions for the two files are identical, output the common permission field. Otherwise, output each filename followed by its permission field. (Hint: Try using the cut utility.)

    I know if i use this script in the following, i can get permission for the file count.txt, but i am not sure how to write this entire problem, can anyone help, thank you.

    ls -l count.txt | cut -c2-10
    assign the result to a variable. Do the same for the other file. Then compare the variables with the if/else control statement.

    2. Write a script that takes a colon-separated list of items and outputs the items, one per line, to standard output (without the colons).
    See here and look for tr (one of the ways). I have helped with your homework. The rest is up to you. read the documentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...