View Full Version : Ask for user input in Bash?

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?

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

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