Hot answers tagged

6

Answer from thrig's comment on OP. Works very well. Change the decimal after sleep to modify the time between lines. sudo find / | awk '{system("sleep .5");print}' Quit with ctrl+z and then kill the job (when using bash); ctrl+c only exits that line. Edit: Did some research based on a comment below. The suggestion awk '{system(sleep.5)||exit;print}' ...


6

If one space at the end of the line doesn't hurt you much: $ awk '{for(i=1;i<=NF;i++) if(i==2 || $i~"hello") printf $i" ";print ""}' file ID23 hello1 ID47 hello2 ID49 hello3 hello4 ID53 This doesn't assume anything about the position of the "hello" string.


5

Never known about the command intel_gpu_time interesting, thank you. This command is part of the package intel-gpu-tools (apt-get install intel-gpu-tools) under Ubuntu and by the look of it the package under RedHat (CentOS) is called exactly the same. So, give yum install intel-gpu-tools a try.


5

pv, the pipe viewer, will let you print one line every second, use it like: cat foo | pv --quiet --line-mode --rate-limit 1 (or, shorter, pv -qlL1). In --line-mode, the --rate-limit (-L) flag defines the number of lines per second that will be printed; the higher the number, the faster the output. It should be available in your distro's repositories (e....


4

This is part of the output of the linuxlogo command, specifically part of the output of linuxlogo -L gnu_linux which in full looks like this screenshot from the Debian version: The logos are constructed from templates that accompany the command. This is the one for the gnu_linux logo. There are 30 logos in the original package. Debian adds a ...


4

This is impossible in general. Once an application has emitted some output, the only place where this output is stored is in the memory of the terminal. To give an extreme example, if this is the 1970s the terminal is a hardcopy printer, the output isn't getting back into the computer without somebody typing it in. If the output is still in the scrolling ...


4

I don't think this will be possible using simple tools like cut. Or, at least, not easily. Here's a Perl solution: $ perl -lane '$k=join " ",grep{/hello/}@F; print "$F[1] $k" if $k' file ID23 hello1 ID47 hello2 ID49 hello3 hello4 Which you could simplify by using grep first: $ grep hello file | perl -lane 'print "$F[1] ", join(" ", grep{/hello/}@F)' ...


3

If its just the output of find you need to rate-limit in this manner, then you can just use find's -exec parameter to perform the sleep for each line: sudo find / -exec sleep 0.2 \; -print


3

A utility that seems to work quite well with handling ansi escapes and input line editing from a typescript is ansi2html.sh which obviously generates html. You can either view this output in your browser and use its printing features, or, if you dont mind losing the colours, convert the html back to simple text with no escapes, eg with ansi2html.sh <...


3

There's two choices: replay the script (with pauses, even via XOFF/XON), and make screenshots which some tool may convert into PDF strip the control sequences from the file, leaving a plain-text file that can be converted into PDF. Generally I've done the latter; both have their pitfalls. When making screenshots, you may not get exactly the picture you ...


3

In a terminal, you generally cannot get all combinations of control- and shift-modifiers to be different values: the basis for control and shift is from US-ASCII (and similar) schemes which defines control and shift for the alphabetic characters plus a few punctuation characters. the combination control+shift usually has no effect, except for special keys. ...


3

A few keys are used as modifiers (shift, control are the most used). Terminal emulators receive a series of X events, which you can see with xev. The terminal emulator combines some of those events such as shifta using X libraries to get A. For other cases such as function-keys and cursor-keys (called "special keys") there is no predefined transformation ...


2

The i3 environment isn't usable in the case described because there's no way to get to a shell. This is a graphical environment (X also known as X11) running in one of Linux's virtual consoles. To switch to a text environment and get a shell, use controlalt together with a function-key for the number of the virtual console that you want to switch to. Most ...


2

Server log says sshd: /etc/ssh/sshd_config: No such file or directory This means the the server is unable to open the file for some reason. Check if the file exists and if it has appropriate permissions (including SELinux labels) ls -lZ /etc/ssh/sshd_config should give you enough information to figure this out (restorecon /etc/ssh/sshd_config should ...


2

Unix sessions are handled by TTY, which should be your starting point. If you use the same user account for all those sessions, then you should be able to send the output directly to the TTY that you want. So you would simply have to call your program with the different TTYs that you want to use in the output and it would be able to open those for output. ...


2

Only if the terminal application was storing the raw output to a file somewhere, as e.g. iTerm does with logging enabled, or some other logging application (autoexpect(1) or equivalent) was saving the output will that raw output be available. Usually this has to be setup in advance, and requires management, e.g. if someone leaves yes running for a while then ...


2

Just ${i} ./processing < base.ppm > picture${i}.ppm Example $ cat foo #!/bin/bash for i in {1..5} do echo ./processing base.ppm picture${i}.ppm done $ ./foo ./processing base.ppm picture1.ppm ./processing base.ppm picture2.ppm ./processing base.ppm picture3.ppm ./processing base.ppm picture4.ppm ./processing base.ppm picture5.ppm $


2

As promised in a previous answer, a simple C program. Why not? Boring day. slower.c #include <stdio.h> #include <time.h> #include <stdlib.h> int main(int argc, char** argv) { int delay; char* rem; if (argc > 1) { delay = strtol(argv[1], &rem, 10); } else { delay = 500; } char* line; ...


2

The easiest thing to do is to for a permanent result is to give the filesystem a label. The way you do this depends on what filesystem you formatted it as. First find the device it is on: $ findmnt /mnt/d1b2aa11-a3e4-434b-b71c-47a8ac23ac23 TARGET SOURCE FSTYPE OPTIONS ... /dev/sdc1 vfat ... For example, above it is on /dev/sdc1 (check this isn't ...


2

This is similar to How to enable Control key combinations for GNU screen on putty?, but addresses a different aspect. In a quick check, it seems that the problem is a conflict between this line set-window-option -g xterm-keys on and this: set -g terminal-overrides "screen*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" Dropping the set-window-...


2

You can do this using the stat command. Here is a simple script which prints the filenames, with some allowances for embedded blanks: #!/bin/sh find $* -exec stat -f '%m %B %N' {} \; | \ awk '$1 == $2 { \ s=length($1)+length($2)+3; $0 = substr($0,s); print $0; }' The %m and %B are respectively the modified and birth times (which appear to be what ...


2

Found the solution myself (in this related question). Use this: echo -e '\x1b[41;37mWarning text\x1b[K\x1b[0m';echo Normal text The documentation says about \x1b[K: K EL Erase line (default: from cursor to end of line). ESC [ 1 K: erase from start of line to cursor. ESC [ 2 K: erase whole line.


2

Clearing to the end of the line will use the current background color with xterm and Linux console, as well as terminals which copy that behavior. In ncurses that is referred to as the background color erase (bce) capability. When the feature is supported, this provides a way to keep the background for the currently-edited line have a given color. However:...


2

The strings aren't actually ANSI sequences. Rather, they started as ANSI sequences, but are translated (due to some scripting error) on your remote machine so that most of the characters are converted to a different form. An ANSI sequence for instance would have escape[A possibly with an optional ; before the A, but the problematic output shows a 133 ([ ...


2

In your loop, there is a short window of time between the "stty echo" at the end of the loop and the "stty -echo" at the next iteration. Keyboard input received during this window will be echoed, even though no read command is waiting for it. If you don't want echoes, don't call "stty echo" 😉


2

The interface between the terminal and the application sends bytes, not keys. Printable characters are interpreted as the byte sequence corresponding to the character encoding of the terminal. Function keys are encoded as escape sequences. There are common conventions for those escape sequences but they aren't completely standardized. For more general ...


2

If you really want to, you could make a program (or shell script) which calls script writing to a timestamped "typescript" file (and in turn calling your real shell) and make that program your default shell in /etc/passwd. There are a few pitfalls: you may have to add this program to /etc/shells doing this sets the SHELL environment variable, which is ...


2

If your goal is to monitor the system, you want pam_tty_audit. As the name implies, pam_tty_audit is a pam module which when configured properly, is invoked any time a user opens a session (and gets a TTY). The module records all input & output, and sends everything it records to the auditd daemon. You can then execute queries against the auditd daemon ...


1

The bindings (whether they appear in the manual or not) appear when you type bind -p For instance (partial listing): "\C-g": abort "\C-x\C-g": abort "\e\C-g": abort "\C-j": accept-line "\C-m": accept-line # alias-expand-line (not bound) # arrow-key-prefix (not bound) # backward-byte (not bound) "\C-b": backward-char # backward-byte (not bound) "\C-b": ...


1

While I do not condone this practice, I will answer the question on how you would go about sshing into your machine, and what you do with it is your own prerogative. With that being said, a few things you may have missed Use your External IP address, not your LAN/WAN IP. The fact that you are using the Port Checker implies that you have done this part, ...



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