Quantcast
Channel: User Dennis Williamson - Unix & Linux Stack Exchange
Browsing all 61 articles
Browse latest View live

Comment by Dennis Williamson on How to get a persistent "history"-file even...

@Diagon: I use a form of my answer here and save the entries in a file separate from .bash_history. I have it record the directory that I'm in when I execute the command along with other information in...

View Article



Comment by Dennis Williamson on cut / grep df -h

If you're going to use grep that way, you might as well simplify it to echo '3.1T'!

View Article

Comment by Dennis Williamson on How can I check if a file can be created or...

Your Bash example requires that zsh is installed. If so, just use zsh directly.

View Article

Comment by Dennis Williamson on Why is bash removing other digits?

MacOS Sierra 10.12.4, Bash 4.4.12(1)-release and en_US.UTF-8: a='0123456789 ٠١٢٣٤٥٦٧٨٩ ۰۱۲۳۴۵۶۷۸۹ ߀߁߂߃߄߅߆߇߈߉ ०१२३४५६७८९'; b="${a//[0123456789]}"; echo "${#a} ${#b}" outputs 54 44 which is what you...

View Article

Comment by Dennis Williamson on Script to change current directory (cd, pwd)

This is the wrong way to go about this!

View Article


Comment by Dennis Williamson on Getting and setting screen size for Xorg

In a multi-monitor setup this will show the dimensions of the bounding box which contains all monitors.

View Article

Comment by Dennis Williamson on First Match - awk

Running grep multiple times in the body of a loop can be extremely slow.

View Article

Comment by Dennis Williamson on bash does not know the letter 'p'

That printf command doesn't belong in ~/.inputrc which doesn't understand commands such as that. It should go in ~/.bashrc or similar shell startup file.

View Article


Comment by Dennis Williamson on Apply brace expansion in "reverse order"

@muru: Oops. Fixed. Thanks.

View Article


Comment by Dennis Williamson on loading a file into an array, processing the...

If you don't know the filename until run time, the idiom is FNR == NR (unless you know of another way).

View Article

Comment by Dennis Williamson on Performance of loop vs expansion

With -a I think -d '\n' is redundant.

View Article

Comment by Dennis Williamson on How can I categorize files in a directory...

Nice! (Requires Bash 4.2 or later.)

View Article

Comment by Dennis Williamson on Why doesn't my Bash script recognize aliases?

@Fmstrat: b () { bash "$@"; } then b -c "echo test | grep test"

View Article


Answer by Dennis Williamson for Convince grep to output all lines, not just...

ack --passthru --color string file for Ubuntu and Debian, use ack-grep instead of ack ack-grep --passthru --color string file

View Article

Answer by Dennis Williamson for Is there a way to run 'screen' in read-only...

You can try: aclchg username -w "#" if you run screen in multi user mode (but I didn't have to do anything special to make it work when testing it as a single attached user). If you do need to enter...

View Article


Answer by Dennis Williamson for Bash scripting rsync puzzler

Please see BashFAQ/050. This fails because of WordSplitting and because the single quotes inside the variable are literal; not syntactical. You should avoid putting commands in variables when shell...

View Article

Answer by Dennis Williamson for How can I convert this bash function to the...

Here is a working function that's similar to your test function. function testvarz switch (count $argv) case 0 echo 'zero' case 1 echo "one $argv[1]" case 2 echo "two $argv[1] $argv[2]" case '*' echo...

View Article


Answer by Dennis Williamson for Change terminal prompt Ubuntu

In Bash 4 and later, you can use the special variable PROMPT_DIRTRIM. The escapes \w or \W are available in at least Bash 3.2 and later. These features can be used to control the length of the current...

View Article

Answer by Dennis Williamson for Bash: how to get the first number that occurs...

I've put your strings in an array so it can easily be iterated for this demonstration. This uses Bash's builtin regular expression matching. Only a very simple pattern is required. It's recommended to...

View Article

Answer by Dennis Williamson for Tmux: equivalent command to screen -d -m -S...

The new-session command with the -d option is similar to the -d -m option in screen. The -s option corresponds to the -S option in screen. Note that -d and -s are options to the new-session command...

View Article
Browsing all 61 articles
Browse latest View live




Latest Images