I have this script to remove the first 4 lines of every file in a folder if their extension is .txt
.
I want to be able to place a file.command with this script in the same folder so I can just double click on it and execute it.
So I made a file with this:
#!/bin/bash
find . -type f -name "*.txt" -exec sed -i.bak '1,4d' {} \;
If I run the file I have all of my Mac txt files 4 lines removed :(
I thought the find .
was meant to stay in the same folder ...
How do I fix it in order to have the command run ONLY in the folder the file.command is?
This code:
find . -maxdepth 1 -type f -name "*.txt" -exec sed -i.bak '1,4d' {} \;
actually works, the issue were:
The created file with the command wasn't made
executable
for that do:chmod +x file.command
Then run the command from the terminal with:
./file.command
No comments:
Post a Comment