New answers tagged

0

All the above answers work - but if the contents inside the tar is within a directory - they won't work the way you want: So this simple trick worked for me: tar -xvzf v<tarball>.tar.gz && mv ./<INSIDE_FOLDER> ./<NEW_FOLDER>


0

In zsh, you can check whether one or more files of type directory and whose name is abc case insensitively exist with: set -o extendedglob # best in ~/.zshrc if () { (($#)); } (#i)abc(/N); then echo such directories exist fi That's an invoking an anonymous function (() { body; } args) where the body is (($#)) to check that the number of arguments is non-...


0

I made a progress bar for rsync (in a wrapper): rsyncy -a FROM/ TO It looks like this: More info on GitHub, install with pip3 install --user rsyncy


2

Check: for file in ./*; do echo mkdir -p "${file%.*}"/cuffcompare/ && \ echo mv "$file" "$_"soft.track done to liner: for file in ./*; do echo mkdir -p "${file%.*}"/cuffcompare/ && echo mv "$file" "$_"soft.track; done Note: Remove echo at above when you were happy with dry-...


1

This depends on the filesystem. BTRFS breaks with this convention. # dd if=/dev/zero of=btrfs.img bs=114294784 count=1 1+0 records in 1+0 records out 114294784 bytes (114 MB, 109 MiB) copied, 0.172979 s, 661 MB/s # mkfs.btrfs btrfs.img btrfs-progs v4.20.1 See http://btrfs.wiki.kernel.org for more information. Label: (null) UUID: ...


3

Is there a command line in a terminal Linux I can use to copy a file to all of these directories? Yes, but it's not something obvious to a beginner tee Directory_{1..4}/file <file >/dev/null Another approach is to use four separate commands cp file Directory_1 cp file Directory_2 cp file Directory_3 cp file Directory_4 or with a shell such as bash ...


4

You probably won't get more efficient than: find /dir -type f -mtime +6 -delete To delete files older than 7 (yes, 7, not 6) days. In any case, you'll need to do one lstat() system call on each file to determine its last modification time. Deleting a file (unlink()ing it from a directory) is expensive as it needs to edit the contents of the directory, ...


1

It's not clear to me exactly what you're wanting to check. Here is to give you some avenues to solve your problem in the zsh shell: #! /bin/zsh - for dir do txt=($dir/*.txt(ND:t:r)) ctl=($dir/*.ctl(ND:t:r)) both=("${(@)txt:*ctl}") txt_but_not_ctl=("${(@)txt:|ctl}") ctl_but_not_txt=("${(@)ctl:|txt}") print -r -- &...


2

#!/bin/bash # Assuming the directory is passed to us as an argument... DIR="$1" SCRIPT=/path/to/the/other/script.sh COUNT=0 for i in "$DIR"/*.txt "$DIR"/*.ctl ;do if [ -f "$i" ] ;then # this is a regular file ((COUNT++)) "$SCRIPT" "$i" fi done if [ $COUNT -eq 0 ] ;then exit 1 # No ....


0

You can do this: cp -r css images js backups ar/ -v Adding -v (verbose flag) will show you the progress.


0

So far the fastest way to do it is still with tar. And with several additional parameters we can also get rid of the difference caused by metadata. To use tar for hash the dir, one need to make sure you sort the path during tar, otherwise it is always different. tar -C <root-dir> -cf - --sort=name <dir> | sha256sum ignore time If you do not care ...


Top 50 recent answers are included