Modify some text of a file in a zip file - linux

On linux, I would like to modify a file that is inside a zip without having to extract it. The file is in any possible extension.
Here's an exemple.
test.zip
|---hello.someextension
|---bye.someextension
The file hello.someextension contains following text: Hello, this is a test.
What I would like to do
Modify the word test in the hello.someextension file to be "gift" instead, for instance.
Modifying the text is not really a big deal, but the issue I'm facing is that I cannot edit a file that is inside a .zip. I tried via VIM and here's an exemple output:
ÅÍ.PE¥&ö$kpì`w_OËŽ=“XÖ¸m† 86=šoÔRw«Õºxÿ¯Ûiö²X

Vim supports editing zipped files out-of-the-box. If it doesn't work for you then you have a local problem of some sort.
Check if it helps to bypass your faulty vimrc (e.g. vim -u NORC -N), or to re-install the whole Vim package etc.

Related

Configuration file pulled from S3 segfaults OpenSwan

I'm trying to configure OpenSwan, an open source IPsec solution written in C.
I have a script to download a configuration file ipsec.conf on an Amazon Linux EC2 that was created on my Macbook and uploaded to S3.
When I start the ipsec service, it segfaults.
Curiously, if I open the configuration file with VIM, make no changes, and simply write/quit, it works. This lends me to believe somehow the file has some weird characters/formatting.
I know of dos2unix, which I ran on the configuration file but that did not prevent the segfault.
I'm wondering what exactly VIM is doing when I write/quit. I could script that operation on my configuration file after pulling it. Or anything else that would help me understand what's going on.
First, try to open the file with vim, then exit vim (:q) without having saved the file before. If vim says File modified since last complete write; write or use ! to override., this means that this is not something that vim does when write/quit that changes your file, but that this is something that vim does when it opens the file. And this is the most common case.
Vim parses the input file depending on the locale, and if some characters can not be understood according to the locale, vim may forget them. So, when saving the file, those characters will be removed.
Now, use vim to save your file as ipsec-ok.conf.
And run the following command:
bash -c 'diff <(od -xa ipsec.conf) <(od -xa ipsec-ok.conf)'
This will display the differences between the original file and the one that works with OpenSwan. In ascii and hexadecimal formats. This way, you will find the unsupported characters that make OpenSwan dump a core.

where is 'my.cnf' file in Linux?

I'm setting MariaDB with Linux up.
And I was going to edit property "bind-address" to accept external connection.
So I need to edit 'my.cnf' file. I found this file and tried to "vi my.cnf" and my linux shows
where can I find "bind_address" property and edit it?
Did i find right file?
From the last two lines in this file, you can see that it loads all the files in /etc/mysql/conf.d/ and /etc/mysql/mariadb.conf.d/. So you also have to look in those directories for a files that have a "bind-address" line.
You can look for "bind-address" automatically using the following command:
grep -r 'bind-address' /etc/mysql/conf.d/ /etc/mysql/mariadb.conf.d/
This command looks for lines containing "bind-address" in all the files in each directory, and for each matching line it will print the filename and the line. You can then edit the files that it finds using your favourite text editor.

vim open existing files

When I want to open a existing file (I use vim filename.java), it seems that I create a new file. Because it says new file. And there is no code.
I don't know why. Can the command vim filename.java open any file in the computer? Should I put my file into a particular place?
Try to search for your file using a number of ways like:
$ locate filename.java
if it doesn't work, try also find
$ find filename.java
(note: you don't have to write the the "$", it's there to mark the start of the command line)
The commands above will give you an output similar to:
/home/jane/FOLDER/FOLDER/FOLDER/filename.java
To edit, write:
$ vim /home/jane/FOLDER/FOLDER/FOLDER/filename.java
Remember to save after edit!

How to use help cmd in Vim to view .txt files?

I'm using Vim 7.4 on Fedora 20. I unzipped all the .txt.gz files in /usr/share/vim/vim74/doc and when I try to use the help command in Vim's command line it gives an error saying E429: File "/usr/share/vim/vim74/doc/starting.txt.gz" does not exist. I did that because when I was using the help cmd before unzipping the files, it showed me some encrypted binary text. So, I thought that uzipping the filed might resolve the problem but, obviously, it didn't. Now, I don't know what to do? Can I configure the file extensions that help searches for in the /doc folder or something like that? What to do?
And yeah, I don't want to compress the files again. A way to resolve this problem without having to re-compress the files, is what I am looking for.
First, delete the old tags file:
rm /usr/share/vim/vim74/doc/tags
Then, run vim as root to regenerate help tags file:
sudo vim -c 'helptags /usr/share/vim/vim74/doc' +qall
Finally, fix vim's ability to read gz files for future convenience.

Vim: How can I create a file after "$ vim file.tgz"?

I want to create a file to tarball, without explicitly opening/extracting it but directly by using Vim. Is that possible?
$ vim file.tgz
:e someNewfile
:w! # how can I create here a file?
Vim handles tar and derived files (including .tgz) using a vimscript called tar.vim. You can see tar.vim's documentation by typing :help tar<CR> inside vim. According to that documentation:
When one edits a *.tar file, this plugin will handle displaying a
contents page. Select a file to edit by moving the cursor atop the
desired file, then hit the <return> key. After editing, one may also
write to the file.
Currently, one may not make a new file in tar archives via the plugin.
So you can edit a file which is already in the tar, but you cannot currently add new files using a vanilla setup of vim.

Resources