Find the answer to your Linux question:
Results 1 to 4 of 4
This is my sample script #!/bin/sh # script to display file system packages and s/w packages ech0 -e " system packages " >> /tmp/infoshell.sh rpm -qa | sort | less ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2006
    Posts
    10

    hi.. help me in scripts


    This is my sample script
    #!/bin/sh
    # script to display file system packages and s/w packages
    ech0 -e " system packages " >> /tmp/infoshell.sh
    rpm -qa | sort | less >> /tmp/infoshell.sh
    echo -e " file system profile " >> /tmp/infoshell.sh
    df -a | cut -d" " -f1 >> /tmp/infoshell.sh
    cat /tmp/infoshell.sh | more
    rm -f /tmp/infoshell.sh

    How to make the file infoshell.sh a userfriendly document?? the output of my script is so vague.
    help me in viewing the o/p.. one should use tab key in scrolling down the o/p page.. plz help
    Ramesh

  2. #2
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    First things first:

    Please place all code in code braces. It makes it much easier for us to read! =D

    Second:
    Code:
    #!/bin/sh
    # script to display file system packages and s/w packages
    ech0 -e " system packages " >> /tmp/infoshell.sh
    rpm -qa | sort | less >> /tmp/infoshell.sh
    echo -e " file system profile " >> /tmp/infoshell.sh
    df -a | cut -d" " -f1 >> /tmp/infoshell.sh
    cat /tmp/infoshell.sh | more
    rm -f /tmp/infoshell.sh
    This can be done more concisely:
    Code:
    #!/bin/sh
    (echo -e "system packages"; rpm -qa | sort; echo -e "file system profile"; df -a | cut -d" " -f1) | less
    I know all of the script being on one line is kind of unclean, but this way you cut out the temporary file and use a better pager (more isn't too good; less is much better).
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  3. #3
    Just Joined! penguintutor's Avatar
    Join Date
    Jun 2006
    Posts
    1
    I'm not sure what you are asking for. Are you wanting the output (currently viewed through more) to be a bit more user friendly.

    If so use the less command, replace

    Code:
    cat /tmp/infoshell.sh | more
    with
    Code:
    less /tmp/infoshell.sh
    You can't use the tab key to move around, but you can now use the cursor keys, and then press x when complete.

  4. $spacer_open
    $spacer_close
  5. #4
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,303
    Hi.
    Quote Originally Posted by Javasnob
    This can be done more concisely:
    Code:
    #!/bin/sh (echo -e "system packages"; rpm -qa | sort; echo -e "file system profile"; df -a | cut -d" " -f1) | less
    I know all of the script being on one line is kind of unclean, but this way you cut out the temporary file and use a better pager (more isn't too good; less is much better).
    I agree with my neighbor to the east, noting that one can write one-"commanders" as:
    Code:
    #!/bin/sh 
    (echo -e "system packages"; rpm -qa |
     sort; echo -e "file system profile"; df -a |
     cut -d" " -f1) |
     less
    because the shell accepts a pipe symbol, "|", at the end of a line to signal that the command sequence will continue on the next line ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

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