![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to list files Created in last 2 hrs | rsonakiya | UNIX for Dummies Questions & Answers | 4 | 03-02-2009 07:25 AM |
| list the file created before 24 hours using ls command | jayaramanit | Shell Programming and Scripting | 7 | 09-11-2007 09:46 AM |
| How to list files with specific created date | Draculla | Filesystems, Disks and Memory | 2 | 05-04-2007 12:45 AM |
| List files created between specific date and time | jazjit | Shell Programming and Scripting | 3 | 04-27-2007 02:19 AM |
| List Files & Folders created/modified | tipsy | Shell Programming and Scripting | 2 | 10-24-2006 02:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I am working on a script that prompts a user name and creates a list in a username.dat file. Furthermore, I have created a sorted_username.dat file. My question is this: My script uses the word "finished" != finished to break the while loop. How can I avoid having the word "finished" show up in my dat files? Many thanks!
|
|
||||
|
variable=" "
echo $variable > name.dat while [ "$variable" != "finished" ] do echo "Please enter your name (type finished when done)" read variable echo $variable >> name.dat sort < name.dat > sorted_name.dat echo $variable done I am a finance guy trying to learn UNIX. Specifically, I am trying to accomplish a few things here. 1) I want the main screen to show the whole list of names typed in during the session (currently as written the main screen only shows the last name typed in). 2) The way this program is written, the sorted_name.dat file shows a blank line at the top of the list due to the initialization of the variable. I would like to eliminate that first blank line at the top of the list through, perhaps, an adjustment of my code. 3) As you can see, I chose finished as the way to quit the loop. It could be any word that quits the loop. I am trying to find a way to NOT have the != string show up in my lists (on the main screen or on the .dat files.) Thank you so much. |
|
||||
|
You can use:
variable=" " echo $variable > name.dat while [ "$variable" != "finished" ] do echo "Please enter your name (type finished when done)" read variable if [ $variable != "finished" ] then echo $variable >> name.dat sort < name.dat > sorted_name.dat fi echo $variable done Good luck. |
|
||||
|
while [ 1=1 ];
do
printf "Please enter your name: (qQ) to quit: "
read choice
case $choice in
"Q"|"q" ) break;;
esac
printf "$choice\n" >> name.dat
done
sort name.dat > sorted_name.dat
Code:
while [ 1=1 ];
do
printf "Please enter your name: (qQ) to quit: "
read choice
case $choice in
"Q"|"q" ) break;;
esac
printf "$choice\n" >> name.dat
done
sort name.dat > sorted_name.dat
Code:
while [ 1=1 ];
do
printf "Please enter your name: (qQ) to quit: "
read choice
case $choice in
"Q"|"q" ) break;;
esac
printf "$choice\n" >> name.dat
done
sort name.dat > sorted_name.dat
|
|
||||
|
Cali, I tried your script...
Cali,
I appreciate your help. I tried running this script you sent me, but when I run it I get a syntax error at line 12...regarding the fi. Could you please help me a little more and please let me know what exactly the fi means/does? Also, will this script eliminate the blank entry at the top of my .dat files? Thank you very much. Quote:
|
![]() |
| Bookmarks |
| Tags |
| learn unix |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|