Tag Info

Hot answers tagged

12

Oooh, I found an explanation. To quote the relevant part: The zsh shell comes with (more than one) great feature(s), such as remote tabcompletion. If you for example want to copy a file over scp, simply hit tab at any part of the filename on the remote host. zsh is able to establish an ssh session on the background, and fetch the related information ...


6

Both are wrong with the zsh default option settings. You can easily see what's going on by using echo as the command instead of mv. Interactively, it looks like you have the null_glob option set. According to the zsh documentation that option is not set by default. What happens with that option unset depends on whether another option, nomatch, is set or ...


3

You can still use read, you just need to print a prompt first. In zsh, -p indicates that input should be read from a coprocess instead of indicating the prompt to use. You can do the following instead, which is POSIX-compliant: printf '%s ' 'erase all directories? (y/n)' read ans


3

Use pkill: pkill blob That would kill all processes matching the pattern blob. Another approach would be killall, but you should call it with -r so that the pattern is interpreted as a regex: killall -r blob


3

In zsh, unquoted variables are not automatically split and glob, while unquoted command substitution will be split into words using values in IFS. In your case, the first command saved content of file /etc/hosts to variable a, echo $a prints value of a variable without split and glob, you get the contents of /etc/hosts (split and glob are not performed in ...


3

You can use xargs to separate them and execute killall for each one : echo $PROCESSES_TO_QUIT | xargs killall -9


3

I'm going to make a first-stage stab at this. Someone else will hopefully improve. Before executing your script, the shell will open a file-descriptor to the file. Usually this is assigned at fd 255. At any rate, if there's an open fd, then lsof can find it. So we use lsof -p $$ and get the highest-file-descriptor's filename. lsof won't work with every ...


2

The reason that every apt-get installation reports the problem with nfs-common is that apt-get is trying to recover from a previous problematic installation of nfs-common. If you run "dpkg -l nfs-common", the first two characters will show a state other than 'ii' (not sure what, but an error state of some sort). The root problem appears to be: ...


2

There are three ways you can solve this. One: just use a function. aliases are for simple text macros, something your second example isn't. sl() { screen -list|grep -v There|grep -v Sockets|awk 'BEGIN { format = " %-35s %-10s %s\n" printf format, "Name", "Active", "Status" printf format, "----", "------", "------" } { printf ...


2

You could create a "normalized" version of each XML file with something like: xmllint --nospace --format orginal.xml > normalized.xml That would get rid of "unimportant"-to-XML whitespace, indent consistently and so forth. After that, you could use cksum to find identical normalized files. I'll suggest a script: for ORIGXML in *.xml do xmllint ...


1

There are heuristics that can help you, but there is no fully reliable way. Otheus shows how to use file descriptors. That's a nice heuristic, which works in most cases. However there are edge cases where it fails, and there's no way to detect failures. Example: take the following script. #!/bin/sh set lsof -p$$ | sed 's/[0-9][0-9]*//' Make two copies ...


1

If the first argument to the script is jobname and the second is command1 && command2 && command3 then the command you build up in the joined variable is something like command1 && command2 && command3>> /path/to/cron/log/dir/May_12_2015/jobname_2015-05-12_01-09-25.log 2>&1 You call eval on this string, and ...


1

You sould start the screen session in you .zshrc without exec, just screen. exec replaces the current process with the new one. So, you will never get back to the original process because it doesn't exist anymore. If started without exec, pstree would then look similar to this (I added -p to pstree to show the PIDs for comprehension): ...


1

Maybe try killall: % export PROCESSES_TO_QUIT='puma rake ...' % export KILL_SIGNAL='killall -9 ' % eval $KILL_SIGNAL $PROCESSES_TO_QUIT


1

You should get all the PIDs and kill 'em all: kill $(ps -ef|grep -v grep |grep java |awk '{print $2}'|tr '\n' ' '); echo or make it more verbose: netikras@netikras-PC ~ $ #ps -ef |grep -v grep |grep java |while read line; do echo "$line" |awk '{$1=$3=$4=$5=$6=$7=""; print "Killing: "$0"\n"}'; kill $(echo $line|awk '{print $2}') && echo KILLED || ...


1

When you run zsh interactively, it reads your ~/.zshrc (and also the system /etc/zshrc but if your administrator isn't naughty that isn't the culprit). You're likely to set a few options there that modify how zsh expands commands, in particular extended_glob (which should be the default, if zsh didn't choose to be backward compatible with the early 1990s ...


1

Same as in ksh: read 'ans?erasing all directories (y/n) ?' Also note that zsh's read has the -q for yes/no answers: if read -q '?erasing all directories (y/n) ?'; then rm -rf -- *(D/) fi It returns true if your enter yes and doesn't require you to press Enter.



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