user2517372
user2517372

Reputation:

Save the current bash script again

Is it possible to resave the running bash script?

I am running a loop in the bash file to do certain operations. After the execution of operations are completed, I want to resave the current bash file without adding any extra code. I just want the file last modified date to be changed.

Current code run.sh looks something like

#!/bin/bash
FILES=/home/shell/test/*

for f in $FILES
do
if [[ "$f" != *\.* ]]
then
  DO STUFF
fi
done

After done, I want run.sh to have current date and possible to do this internally?

Upvotes: 1

Views: 140

Answers (1)

Gergo Erdosi
Gergo Erdosi

Reputation: 42048

You can use the touch command in your script:

touch "$0"

Upvotes: 3

Related Questions