3
I intend to insert in files .py
the stretch below:
-*- encoding: utf-8 -*-
needs to be in specific line, and in large amount of files.
Is there any Unix/linux tool that can perform this task?
3
I intend to insert in files .py
the stretch below:
-*- encoding: utf-8 -*-
needs to be in specific line, and in large amount of files.
Is there any Unix/linux tool that can perform this task?
2
To insert this line, use the command sed:
sed -i '2i-*- encoding: utf-8 -*-' arquivo.py
-i
saves the edits in the file itself2i
insere the string in the 2nd lineTo do this in all python files in the same folder, replace arquivo.py
for *.py
. You can use other wildcard characters supported.
I was failing to use an old version of sed
. Worked great!
Browser other questions tagged python python-2.7
You are not signed in. Login or sign up in order to post.
Something ready I don’t think there is, but I can do this with the
sed
or create a script in Perl.– stderr
I looked for something in
sed
and did not find. I also researched something inawk
.– Alã Damasceno
It has to be in a specific arbitrary line or precisely in the first line?
– rodorgas
It has to be on the second line. @rodorgas
– Alã Damasceno