I keep the batches and shell scripts that I have created so far under a certain folder.
The first line of the file is written differently depending on the time and person you created it.
I'd like to automate this correction.
For example, list and add @echo off,
Want to unify Shebang to #!/bin/bash
How do I create scripts to search and add on Windows and Linux?
Please give me some advice.
Search the batch file and add @echooff
to the beginning if it is missing:
for/f%%fin('grep-iL"@echo off"*.bat')do(
sed-i.bak "1i@echo off"%%f
)
Save #!/bin/sh
by replacing #!/bin/bash
:
$sed-i.bak's/#!\/bin\/sh/#!\/bin\/bash/'/path/to/*.sh
G Assume GNUsed.The -i [SUFFIX]
option leaves a backup called FILENAME.bak
when saving overwrites.
Also, since Windows does not have the grep
sed
command, you must install command-line tools such as Git for Windows or MSYS2 beforehand.
© 2024 OneMinuteCode. All rights reserved.