i need some help with a shell script. I want to start a shell witch is asking for some informations. This should be saved into variables and after entering the informations it should be written in a file.
Something like that:
call shell script
" tell me your name "
John
After this it should write in a file "his name is John"
I know it is a very stupid example, but if i know how to handle this i can adapt this in my special use-case.
Thanks in advance :)
#!/bin/bash
echo -n "Whats your name? "
read name
echo $name > name.txt
It's a bit cleaner to have the read
command print the prompt, using its -p
option:
#!/bin/bash
read -p "Tell me your name: " name
echo "His name is $name" >name.txt
Use echo
to print, read
to read input.
echo -n "Tell me your name: "
read name
echo "Your name is $name."
#!/bin/bash
echo "Tell me your name?"
read name
echo "His name is $name" > name.txt
1. echo -n "Tell me your name: "
2. read name
3. echo $name >> fileName.txt
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.