PDA

View Full Version : Ask for user input in Bash?



Kdar
September 9th, 2010, 02:17 PM
How can I ask for user input in Bash?

I have movie collection, with each movie having it's own directory. And I wanted to add '(YEAR)' in the end of each directory, but since all those movies are different, I want to ask user for input.

I know how to rename bunch of files and add same ending:

for file in * ; do mv $file $file.bak; done


But what can I use to ask for input?

ghostdog74
September 9th, 2010, 02:23 PM
read -p "What's the input? " input

phrostbyte
September 10th, 2010, 11:24 PM
I'd also add the input is stored in a variable called $input in the last case.