-1

I have xxx.sh file which content is:

setsid ./start-meteor.sh >> /home/farah/StudioInstallation/Studio/bricks/platform/log/databricksastro.log 2>&1 < /dev/null &

I want to change the above content to something like:

setsid ./start-meteor.sh >> /home/rose/validation/Studio/bricks/platform/log/databricksastro.log 2>&1 < /dev/null &

I need a Python code to do so.

2
  • What have you tried so far? What part of this is giving you trouble? Why Python specifically? Commented Apr 25, 2016 at 9:36
  • Why don't you make the location of the output logfile a variable in the shell script? Commented Nov 18, 2018 at 14:37

1 Answer 1

0

You can call your python script as any name as you like, say search_replace.py

#!/usr/bin/env python3
import fileinput
import re

for line in fileinput.input(inplace=1, backup='.bak'):
         line = re.sub('farah/StudioInstallation','rose/validation', line.rstrip())
         print(line)

run this script and pass your filename that is xxx.sh as an argument,

$python search_replace.py xxx.sh

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.