I have a python file which works fine. It takes a file and does something on it. So I run it like this:
./MyPy.py File.txt
Then with bash script I grep some part of it.
./MyPy.py File.txt | grep -vE "^color"
So what I want to do is creating a bash file which asks the user for the path of the File and does ./MyPy.py File.txt | grep -vE "^color" in it and gives the result to out put.
Can you please help me with this ?
This should work:
#!/bin/bash
read -e -p "Enter the path of the file: " file
./MyPy.py "$file" | grep -vE "^color"
Additional improvement:
If you want to interpret ~
as /home/user
ie use ~/Downloads
to point to /home/user/Downloads
, then:
#!/bin/bash
read -e -p "Enter the path of the file: " file
file=${file/#\~/$HOME}
./MyPy.py "$file" | grep -vE "^color"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.