11
votes
Accepted
What are the metrics that `file <file>` uses to determine the type of a text-like file?
Most file type detection in file is based on “magic” values, described in a large set of files; TeX files have their own set of detection recipes.
CSV files however are handled differently, with a ...
9
votes
Accepted
Copy a evenly spaced subset of files
Note that brace expansion is not globbing, it will expand regardless of whether words in the result refer to actual files. If you want to copy only those of those files that actually exist, you ...
7
votes
Copy a evenly spaced subset of files
Brace expansion in bash supports steps in the format {<start>..<end>..<step>}:
$ echo file{0..100..19}.txt
file0.txt file19.txt file38.txt file57.txt file76.txt file95.txt
Though it ...
2
votes
Copy a evenly spaced subset of files
There isn't a useful pattern in the set of file names (numbers) you've provided, so the simplest "one liner" you can hope for is:
cp file0.txt file19.txt file39.txt file59.txt file79.txt ...
1
vote
Checking if there's a file with a particular name in a lot of directories
In zsh:
if ()(($#)) **/*.bam(ND.Y1)); then
print There is at least one regular file in here whose name ends in .bam
fi
directories_without_bam=(
**/*(ND/^e['()(($#)) $REPLY/*.bam(ND.Y1)'])
)
if (...
1
vote
Why creating files in /dev/shm is not faster than creating files in /tmp?
I asked myself the same question. Is /dev/shm/ faster than my home directory or /tmp?
I distrust the bash-loop test. Someone else suggested that this should be done in C/C++.
This is my test:
We have ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
files × 4966linux × 815
bash × 534
shell-script × 495
permissions × 452
filesystems × 381
shell × 375
find × 347
directory × 294
command-line × 270
rename × 236
text-processing × 218
scripting × 174
timestamps × 161
ls × 150
awk × 148
rm × 147
grep × 129
filenames × 125
sed × 115
mv × 110
ubuntu × 104
wildcards × 98
file-copy × 92
date × 86