Hot answers tagged

2

If you want to use a regex, then ^([^:]*:){6}[^:]*$ is probably sufficient to match seven fields seperated by : on each line, so you could do: find /store -name passwd -type f -exec grep -hIE '^([^:]*:){6}[^:]*$' {} + > all_passwds.txt -h omit the filenames in the output -I skip binary files -E enable extended regular expressions (ERE)


2

First: The binaries are likely bin/passwd - i.e. the password change tool... Simple solution that might work if all your wanted passwd files are in subdirectories called etc:  find /store/ -wholename '*/etc/passwd' This will only find etc/passwd files, which should be the correct format. If that's not working, construct a loop with the file utility ...


2

If you want to detect an array with empty elements, like arr=("" "") as empty, same as arr=() You can paste all the elements together and check if the result is zero-length. (Building a flattened copy of the array contents is not ideal for performance if the array could be very large. But hopefully you aren't using bash for programs like that...) But "${...


1

The command substitution $(/usr/bin/lsblk ... ) is in double-quotes and the $ is not escaped, so it'll be executed and substituted on the local computer before ssh is even executed. If you want that to be run on the remote system, either use single-quotes instead of double, or escape the $.


1

I use the following script to dpkg-repack all packages that would be affected by an apt-get operation: #!/bin/zsh # # creates subdir and dpkg-repacks all relevant packages in it # DIR=$(date +%Y%m%d) OPER=${@:-dist-upgrade} mkdir -p $DIR cd $DIR || exit 1 zmodload zsh/system renice -n 20 -p $$ >/dev/null 2>/dev/null nproc=$(nproc) function repacked(...


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