list.sh 505 B

1234567891011121314151617181920212223242526272829
  1. # File: list.sh
  2. # Name: D.Saravanan Date: 24/02/2020
  3. # Bash script to read input from user and write/append to a file
  4. touch list.csv
  5. printf "%4s\t%20s\t%3s\t%6s\n" "UniqueID, Name, Age, Pincode" > list.csv
  6. echo "Enter number of records: "
  7. read n
  8. i=1
  9. uniqueid=100
  10. while [ $i -le $n ]
  11. do
  12. ((uniqueid++))
  13. echo "Enter name: "
  14. read name
  15. echo "Enter age: "
  16. read age
  17. echo "Enter pincode: "
  18. read pincode
  19. printf "%4s\t%20s\t%3s\t%6s\n" "$uniqueid, $name, $age, $pincode" >> list.csv
  20. ((i++))
  21. done