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 |
A few tips:
1. Don't use "df" to get the names of the mounted partitions. Use "cat /etc/mtab" (piped into a similar cut) instead. 2. Maybe print some headers, to make the file more readable. ie Code:
echo "###########################" 4. When storing text in a file, don't call it *.sh. People normally assume .sh files are executable shell scripts. Make it something like .txt or omit the file extension altogether (Linux doesn't rely on filename extensions to determine the file type). 5. Don't pipe the output of "rpm -qa | sort" through "less" or "more". "less" and "more" are designed for page-per-page reading of multi-page documents and expect user interaction (ie user should press a key to exit or to show the next page). Edit: I'm not sure what you mean by "one should use the tab key in scrolling down". Please clarify this. |
6. Always spell "echo" 'echo' not 'ech0'. ;)
7. Never write a name like "/tmp/infoshell.sh" more than once. Make it a variable like "INFO". This cuts down on spelling errors causing problems, makes your code shorter & easier to read, and allows you to change the file name in one place (eliminates more spelling errors). |
All times are GMT -5. The time now is 06:32 AM. |