![]() ![]() o -name BAZ.txt -o -name BAZ.csv -o -name BAZ.py ) o -name BAR.txt -o -name BAR.csv -o -name BAR.py \ ( -name FOO.txt -o -name FOO.csv -o -name FOO.py \ To use the array with find, you'd do something like: searchDir="./"įind "$searchDir" would result in the following find command being executed (line breaks added for readability): find. Output from the declare -p is (some line feeds and spaces added to break it up and make it more readable): declare -a findNames=( # If using a version of bash before v4.3, use: ![]() # replace the final '-o' and '-name' in the array with a close parenthesis ![]() Just assume I have a huge list of files that I want to search for as input to find. or, but it's also obvious that this approach is unrealistic if I have a couple of hundred files.įor simplicity, you may also leave aside the extensions. Is there a way to provide a list of files that find should search for, via options or pipes? For every base name I need to run find on the whole searchDir again, which contains quite a lot of files and hence takes a while. The current approach in my bash script is as follows: for bn in $ '(' -name "$bn.txt" -o -name "$bn.csv" -o -name "$bn.py" ')' Then I need to find FOO.txt, FOO.csv, FOO.py. I then need to search for these base names three given extensions.Įxample: Assume one of the base names extracted from the input list is FOO and the given extensions are. To prevent this, use the following pacman hook, which will relink /bin/sh after every affected update:ĭescription = Re-pointing /bin/sh symlink to dash.I need to find a few hundred files, where the base names are provided by some list (let's call it baseNames). Updates of Bash will overwrite /bin/sh with the default symlink. Once you have verified that it will not break any functionality, it should be safe to relink /bin/sh. pacman -Qlq can be used to list all pacman-installed files.$ IFS=: grep -Irl '#!/bin/sh' $PATH |xargs -r checkbashisms All scripts in PATH with a #!/bin/sh shebang:.The following instructions will allow you to find any scripts that may need modification. You can re-symlink /bin/sh to /bin/dash, which can improve system performance, but first you must verify that none of the scripts that are not explicitly #!/bin/bash require any of Bash's features and that all /bin/sh scripts are safely POSIX compliant.įeatures of bash that are not included in Dash ('bashisms') will not work without being explicitly pointed to /bin/bash. Most POSIX compliant scripts specify /bin/sh at the first line of the script, which means it will run /bin/sh as the shell, which by default in Arch is a symlink to /bin/bash. Thus, Dash has a much smaller attack surface, while still having many eyes on its code. Dash is a long-established, tiny project with simple and long-established functionality one that is still very much alive, and with many active developers. As minimalistic as possible - much smaller (134.1 kB vs 6.5 MB installed, 13 kSLOC vs 176 kSLOC) than Bash and others. Very limited resources (disk space, RAM or CPU).Roughly 4x times faster than Bash and others. ![]() Dash (Debian Almquist shell) is a modern POSIX-compliant implementation of /bin/sh (sh, Bourne shell).ĭash is not Bash compatible, but Bash tries to be mostly compatible with POSIX, and thus Dash. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |