New answers tagged

0

To List all PNG and JPEG files which are 7 days old with absolute path. $ find $PWD/ -mtime -7 -print -exec grep -e ".png\|.jpg" {} \; Here $PWD will be added to every file matched.


1

Unorthodox approach: zsh -c 'echo $PWD/**/*.gz(.om[1])' where () after *.gz means to use so called glob qualifiers, i.e.: . consider only plain files om sort by modification time [1] take only first element Obviusly if you are already using zsh you don't need to call it with zsh -c.


1

You can do that by using this command, find "$(pwd)" -type f -name "*.gz" -printf "%T@ %p\n"| sort -n | cut -d' ' -f 2 | tail -n 1


0

(Moved answer from May 2012 from question to here) So now I «fixed» this by re-installing the system. No idea what the problem was. To get the keyboard right everywhere (tty, KDM login screen, KDE) I had to run dpkg-reconfigure locales # Kept only (de_CH|en_US|ru_RU).UTF-8 # Selected de_CH.UTF-8 as default dpkg-...


0

Use the string manipulation constructs of parameter expansion. filename="${NotificationFile#????}" filename="${filename%.csv*}.csv" The first line sets filename to the value of NotificationFile with the first four characters stripped off. The second line removes everything from filename starting with .csv, and re-adds .csv to compensate.


0

If all the filenames end with .csv, and don't contain another .csv anywhere, use eg. sed to remove everything after that: Extract=$(echo $NotificationFile | sed 's/\.csv.*/.csv/') Combining that with what you had before: Extract=$(echo $NotificationFile | sed 's/\.csv_.*/.csv/' | cut -d "_" -f5-) The range N- means "to end of line", ie. not stopping at ...


0

For what you want, you could use sed. This is how I would do it. sed -ne 's/.*\(NB.*\)\_.*$/\FILENAME = \1 /p'


2

In a zip file, only file contents is encrypted. File metadata, including file names, is not encrypted. That's a limitation of the file format: each entry is compressed separately, and if encrypted, encrypted separately. You can use 7-zip instead. It supports metadata encryption (-mhe=on with the Linux command line implementation). 7z a -p -mhe=on Directory....


1

You could create an archive using your favorite tool and then use bcrypt to perform encryption/decryption. A) To create an encrypted file: tar -czf Directory.tgz /path/to/directory bcrypt Directory.tgz This will give you a Blowfish-encrypted file Directory.tgz B) To reverse this process: bcrypt Directory.tgz.bfe tar -xf Directory.tgz


3

pdfunite $(sed 's/$/_*.pdf/' filenames.txt) output.pdf So if filenames.txt contains CSAI_isotig00407:342-556 CSAI_isotig00408:342-556 That command will effectively do pdfunite CSAI_isotig00407:342-556_*.pdf CSAI_isotig00408:342-556_*.pdf output.pdf


2

I recently wrote an example of stuffing a shell one-liner into a find command, and this is another use case for the same. Instead of: find samples \( -iname '*.wav' -o -iname '*.mp3' \) -execdir ffmpeg -i "$(basename "{}")" -qscale:a 6 "${$(basename "{}")%.*}.ogg" \; Try: find samples \( -iname '*.wav' -o -iname '*.mp3' \) -exec sh -c 'ffmpeg -i "$1" -...


3

You seem to assume that --execdir invokes a (Bash) shell that then invokes ffmpeg. That is not the case: -exec command ; Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to the command until an argument consisting of `;' is encountered. The string `{}' ...


1

You can use bash with parameter expansion: $ foo="abc_def_ghi_3432.zip"; echo "${foo%_*}" $ abc_def_ghi


0

With sed, you could try sed -E 's/(.*)_.*/\1/' example, copy paste this into a command prompt % cat << EOF | sed -E 's/(.*)_.*/\1/' abc_def_12345.zip abc_123.zip abc_def_ghi_3432.zip EOF output abc_def abc abc_def_ghi note, this command leaves sed's automatic printing of the pattern space in place, which means any other lines which don't match ...


0

It looks like this is an incompatibility between HFS+ and linux as far as how the filesystems handle these special characters. Some more details here: "Re: File name encoding bug on HFS+ filesystem on Linux?? The problem is still here, and very frustrating. This seems to be an issue with any Linux distribution and Mac OS X. Any file created with Korean ...


5

It isn't an apostrophe in the filename. The filenames that have whitespaces are getting 'wrapped'.



Top 50 recent answers are included