Tag Info

New answers tagged

0

Gert may well be right for the fix. However, I suspect the reason for the incomplete nature of the list of files (breakdowns.R and eventloop.R) is due to those files being the only files in the current working directory that are marked as executable. You can confirm this with an "ls -l" and look at the permissions for something like rwx. If you do not ...


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


0

I don't know abouut showins ls output, but zsh has a nifty feature RPROMPT. Put this in .zshrc and see if it meets your needs: PROMPT=$'%n@%m\n%! %% ' RPROMPT='# %d' That puts current working directory on the right-hand-side of the prompt for me. I include an example of PROMPT with a newline in it, so that if RPROMPT doesn't work as you'd like, you can ...


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


0

Adding a trailing / to the directory name would achieve the desired effect.


0

I found a great plugin for zsh that you can use. If you are using oh-my-zsh then its called gitfast or if just using zsh then you can follow the instructions on his blog article. As the author details there are in fact quite a lot of git completion issues and his efforts are to resolve them all. This is one issue that now works like the way it does in bash. ...


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


0

Try to use for-loop with array instead read: for link in `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` do int[${#int[*]}]=$link done So you'll receive ${int[1]} and ${int[2]} If arrays do not supported by shell: i=0 for link in `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` do eval int$i=$link let i+=1 done


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


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


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


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


0

The following method is maybe a bit tricky but can be a solution to your question. You might create a duplicate of the user by editing the /etc/passwd file and duplicate the line of your user. Only change the username (first field). Set a password for your 'new' user by passwd newuser. Finally change your .zshrc and replace the exec screen with a check on ...


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


0

As stated, bash is commonly available in the default installation for many distros. Your script will not reach the greatest user base by relying on zsh. An important question to answer before designing your script is "Why does it matter which shell a script is executed in?" Different shells use different syntax or offer additional shell functions that ...


0

This is a good question. I have a library of tcsh scripts that have general use. However given the reputation of tcsh .. I need to rewrite them (otherwise they work fine). I think the answer is pretty simple: bash. It has the widest installed base due to GNU/Linux.


3

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


1

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


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


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


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



Top 50 recent answers are included