I can produce on terminal with zsh SHELL a list of 256 colors with the command :
for code in {000..255}
do
print -P -- "$code: %F{$code}Color%f"
done
and currently, I am using dircolors with zsh :
NORMAL 01;37 # global default, although everything should be something.
FILE 01;37 # normal file
DIR 32 # directory
LINK 01;36 # symbolic link
FIFO 40;33 # pipe
SOCK 01;35 # socket
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
# This is for files with execute permission:
EXEC 00;36
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
*~ 05;31 # stuff we hate to find laying around (flashing red)
.mtxt 05;31 # crap
.ndx 05;31
.cmd 00;33 # executables
.exe 00;33
.com 00;33
.btm 00;33
.bat 00;33
.txt 00;37
.pdf 04;94
.docx 00;91
.doc 00;91
.xlsx 00;91
.xls 00;91
#.txt 07;40
.c 00;35 # source code
.h 00;35
.sh 00;36
.py 00;36
.cpp 00;35
.pl 00;36
.pm 00;35
.cgi 00;35
.java 00;35
.html 00;35
.tar 00;31 # archives or compressed (bright red)
.tgz 00;31
.arj 00;31
.taz 00;31
.lzh 00;31
.zip 00;31
.z 00;31
.Z 00;31
.gz 00;31
.jpg 01;35 # image formats
.jpeg 01;35
.JPG 01;35
.gif 01;35
.GIF 01;35
.bmp 01;35
.BMP 01;35
.xbm 01;35
.ppm 01;35
.xpm 01;35
.tif 01;35
.png 01;35
If this possible, how I could use in ~/.dircolors some colors came from the 256 values generated initially in my post ( loop with print -P -- "$code: %F{$code}Color%f" ) ?
Or are there others alternatives to have more colors with ~/.dircolors ?
The numbers used in dircolors are ANSI SGR parameters. Read the linked article for more info. It also lists which numbers correspond to which colors from the 256-color palette.
Related
I have a folder, TestFolder, that contains several .gz files. Each .gz file is a folder containing several sub-directories, with the deepest level of each .gz file containing 5 text files. For example, extracting one of the .gz files ultimately has 5 files at the deepest level of the directory, like:
Users/me/Desktop/TestFolderParent/TestFolder/folder1/subfolder1/subfolder2/subfolder3/subfolder4/subfolder5/subfolder6/TextFile1.txt
Users/me/Desktop/TestFolderParent/TestFolder/folder1/subfolder1/subfolder2/subfolder3/subfolder4/subfolder5/subfolder6/TextFile2.txt
Users/me/Desktop/TestFolderParent/TestFolder/folder1/subfolder1/subfolder2/subfolder3/subfolder4/subfolder5/subfolder6/TextFile3.txt
Users/me/Desktop/TestFolderParent/TestFolder/folder1/subfolder1/subfolder2/subfolder3/subfolder4/subfolder5/subfolder6/TextFile4.txt
Users/me/Desktop/TestFolderParent/TestFolder/folder1/subfolder1/subfolder2/subfolder3/subfolder4/subfolder5/subfolder6/TextFile5.txt
when I run gunzip -r /Users/myuser/Desktop/TestFolderParent/TestFolder in terminal, it extracts all of the .gz files, each as a single text file containing all 5 constituent text files concatenated together. Is there any way to instead run a command to extract each .gz file and return each of the 5 constituent text files as a separate file?
.gz files themselves do not and cannot contain "several sub-directories". The gzip format compresses a single file, and that's it. gunzip will extract exactly one file from one .gz file.
That single file can itself be an uncompressed archive of files. That is often done using the tar archiver, so you end up with a .tar.gz file. Is that what you have? Then you need to use tar, not gunzip to extract the files.
My files name is <09/12/2020>_master. How would I be able to add this file to a .gz archive and then remove the original file?
GZip isn't an archive format, it's a compression format. A .gz file can only contain one compressed file; if you need to put more than one file in at a time, you'll need to pair it with an archive format (such as tar).
Goal is to convert all .wav files to .mp3 in a different location.
The following code works, but creates output files in the same directory.
All the newly created .mp3's are right alongside the .wav's.
for file in /path/to/*.wav; do lame --preset insane "$file" "${file%.wav}".mp3; done
How can I use terminal to convert a drive full of .wav's with lame and output the .mp3's to a different drive? I've tried changing lame's output, but this syntax grabs the entire filename. Looking for the most simple solution.
From the lame manual, the synopsis is very straightforward:
lame [options] <infile> <outfile>
Found the basic concept here
Assuming that the output files should be placed to /output, possible to extend loop to calculate the output file name using the 'basename'
OUT=/output
for file in /path/to/*.wav; do
# Replace .wav with .mp3
out=${file%.wav}.mp3
# Remove directory (anything up to the last '/'
out=${file##*/}
lame --preset insane "$file" $OUT/$out
done
I have a number of compressed archives with the extension .tar.xz. I am advised that, when decompressed, the total size required is around 2TB.
Within the archives are a number of images that I am solely after.
Is there a method to solely extract files for example with the extensions .jpeg, .jpeg and .gif from the compressed archives without having to extract every file?
Thanks
It's trivial to just extract one of the file types; for example:
tar -xjf archive.tar.xz '*.jpeg'
will extract all files with the .jpeg extension. It's important to quote the *, as otherwise the shell would attempt to expand it, and would only try to match only the files that were found (or fail because there were no files with that name).
You can similarly use other patterns like '*.gif', or both together:
tar -xjf archive.tar.xz '*.jpeg' '*.gif'
Because you tag that you're using OSX, I'll skip the need to use the --wildcards option, which is needed when trying to extract only those files under linux.
I'm converting a PDF file to separate images using this command:
-sDEVICE=jpeg -o page-%02d.png X.pdf
This outputs the files as:
page-01.jpeg, page-02.jpeg, and so on.
However, I want to output the files with this file name:
X-page-01.jpeg, X-page-02.jpeg, and so on.
Is it possible to do this with GhostScript?
Well yes, clearly its possible:
-sDEVICE=jpeg -o X-page%02d.jpeg X.pdf
(I presume that you actually meant page-%02d.jpeg, rather than .png, since you are specifying the jpeg device).
No, Ghostscript won't automagically prepend the input filename to the output filename, you have to do that yourself.