Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Hot answers tagged

8

On some Unix-style systems (BSDs and macOS), CtrlT sends SIGINFO to the running process. Some commands handle this directly; otherwise, it’s handled by the kernel, and that’s what produces the output you’re seeing. SIGINFO on GNU Linux (Arch Linux) missing has more on the topic.


5

Your variables are quoted, you don't need to escape the spaces: SYSDIR='/Volumes/Macintosh HD/System/' (etc.) Also (tangentially) related: Are there naming conventions for variables in shell scripts?


2

If you want to remove everything after the first semicolon in each row: With cut: cut -d';' -f1 file -d';' use semicolon as delimiter -f1 print the first field With awk: awk -F';' '{ print $1 }' file Similar to cut: Use semicolon as input field separator and print the first field. With sed: sed 's/;.*//' file Substitute semicolon and any following ...


1

It's not easy for an application running in a terminal to know if the terminal is in focus or not. The terminal itself can help you out though. Here are your options with macOS terminals: Terminal.app In Profiles → Advanced → Bell you can turn off the audible bell, but turn on "Bounce app icon when in background". iTerm2 Similarly to Terminal.app, in ...


1

With your perl command, you always print the line because you have -p option. The match part doesn't do anything. You want -n and print the matching part: ls -1 *9000.jpg \ | perl -lne 'print $1 if /^(.+)(?=_.+_.+)/' As filenames may have newlines, you should modify this to read zero-delimited filenames although, in your case that may not be needed: ...


1

Your OS contains many small and simple tools that do text processing. In this case I would use cut : cut -d; -f1 <FILE >tmpfile && mv tmpfile FILE


1

As it is the first column I think (GNU) sed is enough. Assuming that the column separators are tabs: sed -E 's/^(.*);.*\t/\1\t/' file


1

If you're using bash or zsh, the shortcut !$ works in the same fashion. For example: [user@localhost ~]$ echo "test" >> new_file [user@localhost ~]$ cat !$ cat new_file test


1

Or if you prefer relative paths, you could determine the absolute path to the script's directory with the help of the BASH_SOURCE array variable which holds the path to the script: scripts=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd) cp -R "$scripts"/../bar/x "$scripts"/.. GNU's cp doesn't care if -r or -R is used, but the BSD man page lists -r as ...


1

The streaming messages are part of a binary log file. Apple are moving to a unified logging system, so the logs do not work the same way anymore, at least by default. One might try to configure syslogd and/or ASL (Apple System Logger) via one or both of the configuration files, /etc/syslog.conf and /etc/asl.conf. (There are many more configuration files for ...


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