views:

63

answers:

1

Hi I have a file try.SPEC. This file contains a word "Version: 1.0.0.1" . Now I want to write a shell script which will read the version number from keyboard and insert in the file. eg- if the user enters the version number as 2.1.1.1 then the file will have Version: 2.1.1.1" instead of "Version: 1.0.0.1". like this i want that i must be able to change irrespective of knowing what is the version number present in the spec file

Thanks Sunil Kumar Sahoo

+1  A: 

you can use read to get a user input

#!/bin/bash

read -p "Enter version: " version
while read -r line
do
 case "$line" in
  *Version*) line="Version: $version";;
 esac
 echo "$line"
done <"path_to_file"  >temp
mv temp file
ghostdog74
where i will give the path of file ?
Deepak
the input redirection to the while loop.
ghostdog74