Zsh - How to source for the same name file inside subdirectories and exclude specific directories? - directory

for file in $LIB_DIR/*/config; do
source $file
done
I have to look up all the subdirectories that contain the config file, but I want to exclude two specific directories from being read the same name config file.

Related

UNIX: how to zip a folder that contains more folders w/o including any of the folder paths

I' m trying to zip a folder that contains some .json files plus subfolders with more .json files. I need to zip the parent folder with everything included without containing any of the parent or subfolders paths. Is there any way I can do this?
Thank you
EDIT:
I want this:
pending_provider/722c9cb2-268b-4e4a-9000-f7f65e586011-version/1d296136-ac87-424e-89c4-682a63c7b853.json (deflated 68%)
But not this:
pending_provider/722c9cb2-268b-4e4a-9000-f7f65e586011-version/ (stored 0%)
I want to avoid the "stor" compression type which only saves the folder path. I want only the "defN"
So the -j doesn't help me a lot
Thanks
If you don't want any paths at all you could use the -j option. Below is the man page entry for the option.
-j
--junk-paths
Store just the name of a saved file (junk the path), and do not store
directory names. By default, zip will store the full path (relative to
the current directory).
If you just want to exclude directories
-D
--no-dir-entries
Do not create entries in the zip archive for directories.

How to put files in a folder and generate .zip file?

I want to generate a .zip file which contains some files and folders. The file inside the folder might be contained in some other paths and I want to put files in another folder and generate a .zip file from them.
By other words, I don't want to physically generate the folder with files. The files might be on some roots and I want to generate folder virtually to put them on the .zip file.
Imports System.IO.Compression
ZipFile.CreateFromDirectory("source","destination.zip",CompressionLevel.Optimal,False)
As an example if I have these files on my website:
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
I want to put them on a zip which when I extract it, the files will be as follows:
- ~/files/1.jpg
- ~/files/2.pdf
- ~/intro.docx
For the source put the root folder and it will do it
example :
This is yours
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
But before this there is a root folder whic is the ~ just simpily put as a source

How to stop git (.gitignore) from tracking minqueue (wordpress plugin) cached changes

After entering "git status", I keep getting messages like wp-content/uploads/minqueue-cache/minqueue-9cbb4cb4-9cb6af13.js
even though I have added the following line to .gitignore file: /wp-content/uploads/minqueue-cache/*
. Why is this?
The slash in the beginning of /wp-content/uploads/minqueue-cache/* means starting from the directory where the .gitignore file is in, so your pattern will match all files and folders inside wp-content/uploads/minqueue-cache/ but not the files inside www.apis.de/wp-content/uploads/minqueue-cache/.
If you change the pattern to wp-content/uploads/minqueue-cache/* it will match all files and folders in all wp-content/uploads/minqueue-cache/ folders, no matter where they start.
If you change the pattern to /www.apis.de/wp-content/uploads/minqueue-cache/* it will match all files and folders exactly in this one directory.

zipping the files in unix having extension after

I have a logs file at directory cd /opt/app/logs named as
coa.log.1
uoa.log.2
erete-rere.log.1
now my concern is that i am looking for unix command which will zip the files having extension log.1 or log.2 or having log. extension anything
request you to please advise the unix comand to zip these files
Folks please advise for this
You can compress in a lot of formats in unix. The most commom is the tar.gz extension. If you are looking fot .zip specifically, there is a zip command: zip <zipname> <files>
To pass the file list you may use the * wirldcard, indicating any name. For example: *.log.*, as sugested by glen, will match every file that contains .log. in its name.
You probably want something like this:
zip backup_logs.zip /opt/app/logs/*.log.*
This will zip all files in the folder that matched what you asked and create a zip file in your current directory.

How to copy selective folders into a different directory

folderA contains [dirA, dirB, dirC, fileA, fileB]
I want to copy folderA to folderA-copy without dirB and dirC how should I do that?
Use rsync command exclude option which provides you with option to enter regex for folder/files or specify a file containing all the directories you want to ignore or specify particular directory or file.

Resources