Link to home
Start Free TrialLog in
Avatar of SurferBob1064
SurferBob1064Flag for Australia

asked on

how do i convert bash script to python script

cat testfile | while read line; do echo this is line nr $line ; done

testfile has line data of :
1
2
3
4

Output:

this is line nr 1
this is line nr 2
this is line nr 3
this is line nr 4

I want the python equivalent of this bash script.

Many thanks
ASKER CERTIFIED SOLUTION
Avatar of pepr
pepr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SurferBob1064

ASKER

The solution works 100% and I appreciate the explanation. Elegantly done.
Avatar of pepr
pepr

You are welcome. And welcome on the Python board ;)