Changing file scripts using bash shell

do anyone know specifically how to do this? Been search around forums, guides and videos from youtube.
specifically i wanted to change part of a text specifically in a file call text01.sh which contents are:

!/bin/bash

clear
read -p "Press Enter to Start."
echo -e "Please enter your name: "
read name
echo "Nice to meet you, $name"

the text i want to edit is line of "Press Enter to start." to "Shift to start"
any help would be appreciated.

sed -re 's/Press Enter to Start\./Shift to start/' file.sh > /tmp/file.sh && mv /tmp/file.sh file.sh

Although I have no idea how you expect to read keypress for Shift. read won't work.

2 Likes

so wait sed actually helps change the line for this?

Basically he's using sed as a search and replace. In other words he says "sed search for 'Press enter to Start' and replace it with 'press shift to Start' within file.txt and then instead of writing it to the console write it to the file '/tmp/file' and then move that file to file.txt.

To you it'll look like it just replaces the text though.

1 Like

oh ok

Thank you all for your help I'll try to figure out the alternative name for the Shift key or a different command than read but Thank you for all the help :)