Tag Info

Hot answers tagged

14

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 ...


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 ...


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 ...


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

Your use case is not very convincing. Most people include the current directory as part of their prompt; zsh has extremely rich prompt configuration possibilities (including multiline prompts, left and right prompts, etc.). With completion (which again in zsh is very configurable), you can show lists of files in the contexts where you need them. That being ...


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

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


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

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

I stole this from drupal.org, but you could do something like this: while [ $# -gt 0 ]; do case "$1" in --p_out=*) p_out="${1#*=}" ;; --arg_1=*) arg_1="${1#*=}" ;; *) printf "***************************\n" printf "* Error: Invalid argument.*\n" printf "***************************\n" exit 1 esac ...



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