Find the answer to your Linux question:
Results 1 to 4 of 4
hey guys, i am doing linux at school and i was doing some homework out of a book and just needed help on a few questions. i am new to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Posts
    10

    need help with some bash scripts


    hey guys, i am doing linux at school and i was doing some homework out of a book and just needed help on a few questions. i am new to bash scrpits so i am just after some advice. thank you.

    Question 3

    Write a shell script called lastname.sh that lists all the last names of all users
    that have a valid account (sorted from A-Z) located in the password file /etc/passwd.
    The user must input the file name.


    Question 7

    A file called mywork.txt is has 50 lines of text. What command would copy
    lines 15-35 to another file called middle.txt

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Regarding question 7 I suggest that you google for awk tutorial.
    Regarding 3 the most difficult part can be done using sort.Check
    the man page for it.

  3. #3
    Just Joined!
    Join Date
    Aug 2005
    Posts
    10
    for question 7 i tried

    cat mywork.txt | head 35 | tail 20 > middle.txt

    that seemed to work okey. thanks for the advice on both questions mate. i'll try question 3

  4. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Quote Originally Posted by wing_zero
    for question 7 i tried

    cat mywork.txt | head 35 | tail 20 > middle.txt

    that seemed to work okey. thanks for the advice on both questions mate. i'll try question 3
    Simplest ways are the best:
    Code:
    sed -n '15,35p' mywork.txt >middle.txt
    No point using three processes when one will do.

Posting Permissions

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