Skip to main content

New answers tagged

0 votes

Macbook air boots directly to grub menu, can't access BIOS or Boot menu anymore

That seemed an hardware issue for the keyboard. As the keyboard wasn't working fine at times after booting inside Linux too, I gave Linux multiple boots to find keyboard working and not workIng ...
kan's user avatar
  • 1
1 vote

Macbook air boots directly to grub menu, can't access BIOS or Boot menu anymore

Macbooks are not PCs, and they don't have a PC-style BIOS at all. A 2017 Macbook Air would be an Intel-based one. So the applicable boot-time keypresses are listed in this Apple Support article. If ...
telcoM's user avatar
  • 99.2k
0 votes

What is the header/certificate format used in /etc/ssl/cert.pem?

You've placed the -text option on the end of the 2nd openssl command, so that it outputs a text representation (oddly enough!) of the certificate. Also, s_client sends some info to stderr which you ...
garethTheRed's user avatar
  • 34.1k
0 votes

zsh: command not found: yt-dlp

You're missing the absolute path to your standalone executables from $PATH, which is why your Mac can't find yt-dlp. (The $PATH variable contains an ordered colon-separated list of directories in ...
Chris Davies's user avatar
0 votes

Extract YouTube video IDs from the end of filenames

Assuming that the initial part of the name that is not a YouTube video ID always contains at most one internal dash and one terminating dash, then the part of the name that we must remove to get the ...
Kusalananda's user avatar
  • 337k
0 votes

Extract YouTube video IDs from the end of filenames

If you always have two hyphens before your intended string, then here is one way of doing that: $ sed 's/-/ /2' mp4_files | awk '{print $NF}' rr-9w2gITDM.mp4 WwitBbsUvc8.mp4 The sed part simply ...
dhm's user avatar
  • 1,663
0 votes

Extract YouTube video IDs from the end of filenames

This is perhaps easier with awk, since that makes it easy to simply extract the last n characters of the filename: $ ls -1 '1 - How to make an operating system from scratch-rr-9w2gITDM.mp4' '2 - How ...
larsks's user avatar
  • 35.6k
0 votes

zsh: command not found: yt-dlp

You have Homebrew already installed, to install yt-dlp: brew install yt-dlp brew upgrade yt-dlp Returning to the problem, the binary isn't in your PATH or you have used an invalid binary. Here is how ...
GAD3R's user avatar
  • 67.2k
1 vote

How to find file names with non-printable characters using BSD `find -regex`?

In a POSIX-compliant find implementation (doesn't include FreeBSD's, but should include macos which has been certified as being compliant even if its POSIX utilities are based on FreeBSD's): find . -...
Stéphane Chazelas's user avatar
3 votes

How can I only execute sed commands after so many pattern matches in macOS?

With awk, count the number of times we match pattern and use getline to read the next line once we reach the count of two. After printing the line, we may quit. $ awk '/^pattern$/ && ++count ==...
Kusalananda's user avatar
  • 337k
2 votes
Accepted

How can I only execute sed commands after so many pattern matches in macOS?

Try this command: $ sed -n '/pattern/{n;p;}' input.txt | sed -n 2p line 4 For fifth instance use 5p instead of 2p etc. Hardly any need for explanation.
dhm's user avatar
  • 1,663
1 vote

Rename files to random filenames (but not to checksums)

Use the mktemp command with template and other flags of your choosing: https://ss64.com/mac/mktemp.html This command generates a unique random file name that does not already exist, creates an empty ...
Ben's user avatar
  • 121
2 votes

What does a leading colon in a sh script line means?

On a macOS Sonoma, where GNU Bash 3.2.57 (an old version) is used as sh, the invoked help command issued from within sh (which is that old version of bash) describes it as: "No effect; the ...
PRouleau's user avatar
  • 171
2 votes

Rename files to random filenames (but not to checksums)

Another approach is to regenerate the random name as long as a file with the first random name exists. Something like this: randomname() { base64 < /dev/urandom | tr -dC a-z0-9 | head -c4; } for f ...
terdon's user avatar
  • 244k
3 votes

Rename files to random filenames (but not to checksums)

First, I suggest that if you've got the same checksum you've probably got the same contents. It may be desirable to preserve duplicates in all but name. In that case use the name as (some of) your ...
Chris H's user avatar
  • 205
9 votes
Accepted

Rename files to random filenames (but not to checksums)

You can just rename the files to an incremented number, only process them in random order. random() REPLY=$RANDOM n=0; zmv '*(.*)(#qo+random)' '${(l[8][0])$((++n))}$1' Here using the l[length][pad] ...
Stéphane Chazelas's user avatar
1 vote
Accepted

Understanding the '-a' option of the 'cp' command

The -P, -H and -L standard options are mutually exclusive. Setting one unsets the other two. The last one (from left to right) wins. -LHP is the same as -P, -HPL is the same as -L. Now when the doc ...
Stéphane Chazelas's user avatar
5 votes
Accepted

cp -P * vs. cp *(.) vs. cp *(-.)

cp -P -- * foo/ (I've added the missing -- without which files starting with - could be treated as options by cp) would copy all files into foo/. For files of type symlink, that would copy the symlink ...
Stéphane Chazelas's user avatar
4 votes
Accepted

Replace any number of spaces with a single underscore

What you want here is the equivalent of the regexp + operator which in zsh with extendedglob on (and zmv does enable extendedglob) is the ## glob operator. The :s/.../.../ modifier from csh doesn't do ...
Stéphane Chazelas's user avatar
7 votes
Accepted

Does 'ls' ignore Zsh glob sorting qualifiers?

ls does its own sorting. To disable that, and display the files as they are given (by the glob expansion), use -f on macOS: ls -f -- *(oL) To list directories without listing their contents, add -d. ...
Stephen Kitt's user avatar

Top 50 recent answers are included