Shell scripting ....
Hi All,
I'm trying to write interactive shell script. which will ask user to provide path where the files would be stored. Since this path contains "/" (for.eg. /home/msk/current/log) how can i make this readable using read. Following is the script #!/bin/bash echo "Enter the path to search" read DIR HOMEMS=$DIR for X in $DIR/* do awk -F';' '{print $1}' >> /home/msk/output.file echo -n "#" done Please guide me. Regards, MSK |
Quote:
Code:
echo "Enter the path to search" Code:
echo -n "Enter the path to search: " |
Quote:
Specifically, what do you mean by "Since this path contains "/" (for.eg. /home/msk/current/log) how can i make this readable using read."? The read command reads from stdin (standard input, usually the terminal); it has nothing to do with making directories readable which is done by the chmod command. In the script, in the loop you do exactly the same thing each time through because the only thing that changes is $X and it is not used in the loop. Actually the loop will hang because there is no input specified on the awk -F';' '{print $1}' command so it reads stdin; the awk command will wait for input. When posting code, it is easier to read if you use code tags (that's a link so you can easily find out about them). |
Not sure what you want to achieve! Possibilities are:
1. ask directory as input, then copy a bunch of known files to that location 2. ask directory as input, then copy all files from that location to a known other location 3. ask directory as input, then read a list of filenames from a file passed as a script argument, and copy those files to the given location Programming or scripting is difficult, if it is not known what needs to be done exactly! |
All times are GMT -5. The time now is 04:45 AM. |