Hot answers tagged

5

In a small python script: #!/usr/bin/env python3 import os import sys src = sys.argv[1] for root, dirs, files in os.walk(src): for dr in dirs: directory = root+"/"+dr if len([sub for sub in os.listdir(directory) \ if os.path.isdir(directory+"/"+sub)]) == 0: print(directory) To use it Copy it into an ...


4

l is an alias for ls -CF the -F option for ls gives file type; the / means the file is a directory. the -C option for ls arranges output in columns For more options to ls see man ls To see all aliases defined in the system just type alias Some default aliases relating to ls (notice that ls itself is an alias!) alias l='ls -CF' alias la='ls -A' alias ll=...


4

This little script will make sha512sums of a folder and all its subfolders and save it to a file called sha512checksums: #!/bin/bash rm -f sha512checksums find -type f ! -iname "sha512checksums" -exec sha512sum "{}" + > sha512checksums And this following scrip lets you check the sums based on the before created file: #!/bin/bash rm -f sha512errors ...


4

A simple find should be enough: find /path/to/dir -type d -empty For example: $ tree foo foo ├── 1 │   ├── 1 │   ├── 2 │   └── 3 ├── 2 │   ├── 1 │   ├── 2 │   └── 3 └── 3 ├── 1 ├── 2 └── 3 12 directories, 0 files $ find foo -type d -empty foo/2/2 foo/2/3 foo/2/1 foo/3/2 foo/3/3 foo/3/1 foo/1/2 foo/1/3 foo/1/1 $ touch foo/1/1/a foo/2/1/a foo/...


2

Your issue seems to be that you are not in the same folder as the file tor-browser-linux32-5.5.5_LANG.tar.xz, so the file is not found, as you don't say where you downloaded the file, I can't tell you how to get to it but if it is in your /home/downloads run cd ~/Downloads then tar -xvJf tor-browser-linux32-5.5.5_LANG.tar.xz to extract it, and keep ...


2

Just run: rm * It's that simple. It won't touch the directories unless you add the -R or -r flag: rm -r * If you also want to delete empty directories, add the --dir flag: rm --dir *


2

You could do a find-within-a-find e.g. find . -type d -exec bash -c ' [[ -z $(find "$1" -mindepth 1 -type d -print -quit) ]] && printf "%s\n" "$1" ' bash {} \; If you don't want the leading path components, then find . -type d -exec bash -c ' [[ -z $(find "$1" -mindepth 1 -type d -print -quit) ]] && printf "%s\n" "${1##*/}" ' ...


2

Try this: find . -type d -print0 | sort -z | gawk '{a[$0]; sub(/[/][^/]*$/, ""); if ($0 in a) delete a[$0]} END{for (d in a)print d}' RS='\0' How it works To be safe for all possible directory names, we use nul-separated lists for each step of the pipeline. find . -type d -print0 This gets a list of all subdirectories of the current directory. sort -z ...


2

Using inotifywait As mentioned, you can use inotify-tools (inotifywait) to watch a specific directory for changes, for example by the script below, and subsequently set new files executable recursively. The script uses the inotifywait -command, which is triggered by specific events, set by the -e -option. Luckily the command can be used in combination with ...


1

No. You could use inotify to watch the directory and chmod new files. Here is how to find out about inotify: man -k inotify for i in $( man -k inotify | awk '{ print $1 }' ) ; do man $i read -p "Print?: " ans if [[ "x$ans" = "xy" ]] ; then man -t $i | lpr -J $i fi done # sr is from surfraw, Shell Users Revoultionary Front ...


1

Not a dupe, but in the accepted answer on this question, it is explained how to run a script (or any command) whenever a file is added or created in an arbitrary directory. In your case, the only needed event- trigger is: -e create Furthermore, since you are not using the path to the file as an argument, you can skip the --format -section. The script to ...


1

Best to use absolute paths so you don't change again things you need to stay how they are. So the below commands will make your old home directory readable for you. # this makes only the home directory in the old drive owned by you sudo chown -R mickey:mickey /media/f806aa57-553c-43bc-8338-37851dc128ad/home So now that you have done this I assume you want ...


1

rm without the -r, disabling recursive directory removal flag and shell globbing: rm /path/to/dir/* Add the -f if you don't want to be prompted. You can also use find: find /path/to/dir -maxdepth 1 -type f -exec rm -rf '{}' \; which works because of a maxdepth of 1, thus selecting only top-level files.


1

You can simply do that by giving the /virusScan/quarantine directory different permissions. sudo chmod 664 /virusScan/quarantine This way you can read and write to the directory but not execute something from it, the group has as well the same permissions to read and write but not execute and others only can read.


1

In Ubuntu GNOME 16.04 with GNOME 3.20 there is now such an application called Search and Indexing (or tracker-preferences) installed by default (if it is not installed or if you are running a previous version which does not have it pre-installed then it can be installed by running sudo apt-get install tracker-preferences) which one can use to highly flexibly ...


1

Just to clarify it a little more (hope i do not miss any special filesystem): Folders are a small file Folders grow as more files / sub folders are added to it (but not to a sub folder of it), only directly to it Folders (on some systems do not) decrease on size when files / sub folders directly on it are removed from it Think on folders as a phonebook ...


1

For me the problem is NOT solved by checking Auto-Raise, rather, by changing Focus Prevention Level from Low to Off in ccsm.



Only top voted, non community-wiki answers of a minimum length are eligible