I have a bash script (seen ) that I'm using to sort a list of files in subdirectories by filename.  This script appends sorted files in hooks/pre-relevant/, then files named hooks/pre-relevant, then files named hooks/relevant, then sorted files in hooks/relevant/, using the append_hook function below:  hooks=()  # Run a hook script, if it's executable, with the input from this invocation append_hook () {   if [[ -f "$1" &amp;&amp; -x "$1" ]]; then     hooks+=("$1")   fi }   I'm testing it with this directory structure:  testing-range/plugins/ |-- bar |   `-- hooks |       |-- irrelevant |       |-- only-one |       `-- relevant |-- dickory |   `-- hooks |       `-- pre-relevant |-- doc |   `-- hooks |       |-- perl-envsubst |       `-- relevant |           |-- 00 |           `-- 20 | |-- factory |   `-- hooks |       `-- relevant `-- hickory     `-- hooks         |-- pre-relevant         |   `-- 30         `-- relevant             `-- 10   When I use this multi-step array code to append the files:  append_numbered_hooks () {   # Gather every file into an array, prefixing each item with the   # filename of the script (its position in sort order)   local filelist=()   for hook in "$PLUSHU_ROOT"/plugins/*/hooks/"$hookname"/*; do     filelist+=("${hook##*/}/$hook")   done    # Sort the array numerically   printf '%s\0' "${filelist[@]}" | sort -nz | IFS= read -rd '' -a filelist    # Append each script in sorted order   for hookline in "${filelist[@]}"; do     append_hook "${hookline#*/}"   done }   I get almost the correct output:  hickory/hooks/pre-relevant/30 dickory/hooks/pre-relevant bar/hooks/relevant factory/hooks/relevant doc/hooks/relevant/00 doc/hooks/relevant/20 hickory/hooks/relevant/10   Yet, when I append the files using this simpler pipeline:  append_numbered_hooks () {   for hook in "$PLUSHU_ROOT"/plugins/*/hooks/"$1"/*; do     printf '%s\0' "${hook##*/}/$hook"   done | sort -nz | while IFS= read -rd '' hookline; do     append_hook "${hookline#*/}"   done }   The numbered files don't show up in a for "${hooks[@]}" loop:  dickory/hooks/pre-relevant bar/hooks/relevant factory/hooks/relevant   What's going on? The correct values should be:  hickory/hooks/pre-relevant/30 dickory/hooks/pre-relevant bar/hooks/relevant factory/hooks/relevant doc/hooks/relevant/00 hickory/hooks/relevant/10 doc/hooks/relevant/20
I'm trying to write a simple bash function that takes, as its arguments, a number of files and/or directories. It should:   Fully qualify the filenames. Sort them. Remove duplicates. Print all that actually exist. Return the number of non-existent files.   I have a script that almost does what I want, but falls down on the sorting. The return value of the script as it stands is correct, but the output is not (unsorted and duplicates). If I uncomment the | sort -u statement as indicated, the output is correct but the return value is always 0.  N.B. Simpler solutions to solve the problem are welcome but the question is really about why is this occurring in the code I have. That is, why does adding the pipe seemingly stop the script incrementing the variable r?  Here's the script:  function uniqfile {     local r=0       for arg in "$@"     do           readlink -e "$arg" || (( ++r ))      done #| sort -u    ## remove that comment      return $r }
My machine is continously making udp dns traffic request. what i need to know is the PID of the process generating this traffic.  The normal way in TCP connection is to use netstat/lsof and get the process associated at the pid.  Is UDP the connection is stateles, so, when i call netastat/lsof I can see it only if the UDP socket is opened and it's sending traffic.  I have tried with lsof -i UDP and with nestat -anpue, but I can't find wich process is doing that request because i need to call lsof/netstat exactly when the udp traffic is sended, if i call lsof/netstat before/after the udp datagram is sended is impossible to view the opened UDP socket.  Call netstat/lsof exactly when 3/4 udp packet is sended is IMPOSSIBLE.  How I can identify the infamous process? I have already inspected the traffic to try to identify the sended PID from the content of the packet, but is not possible to identify it from the contect of the traffic.  Anyone can help me ?  I'm root on this machine FEDORA 12 Linux noise.company.lan 2.6.32.16-141.fc12.x86_64 #1 SMP Wed Jul 7 04:49:59 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux Replace arbitrary characters in the middle of an IP address string with sed I need to find and replace either one or two numerical characters in strings in a file.  The strings are IP addresses of the form:   10.xx.y.z    Where xx can be one or two characters.    I want to replace the xx with the single character 0, so I have  10.0.y.z    preserving the values of y and z.   The string may appear multiple times in the file.  What is the sed invocation to do this? From the  on the dual of a norm:  $X$ and $Y$ are normed spaces, and we associate with each $f\in L(X,Y)$ (the space of bounded linear operators from $X$ to $Y$) the number $$\|f\| = \sup\{|f(x)|:x\in X, \|x\| \leq 1\}.$$  At some point in the proof that $L(X,Y)$ is bounded, it seems like they use the inequality $$\|fx\| \leq \|f\|\cdot\|x\|,$$ where $\|x\|\leq 1$.  I can't see why this should holds.   $\|f|\|$ is the supremum of what $|f(x)|$ can be, given that $\|x\|\leq 1$. So, given that $\|x\| \leq 1$, $|fx|$ should be bounded by $\|f\|$. But why should it be bounded by $\|f\|\cdot\|x\|$? How to remove items from a list while iterating? Schengen visa permit I am a student with a Singapore passport currently studying in the Czech Republic for a semester. My permit is valid until 2nd of February, I plan to fly to the UK to travel for 3 days before heading back to Singapore from there.  Would there be any problems, such as exit immigration from the Czech Republic to the UK? I searched online that the UK is not part of Schengen Area Agreement states, and my passport has a visa free entry to the UK. I want to extend my volume. However the unallocated space lies ahead of the volume. Is it possible to extend this volume without converting it to a dynamic volume?     I tried to use diskpart with the extend command but it doesn't work. Makes sense because the instructions says that the unallocated space has to be behind the volume. Tracking down where disk space has gone on Linux? When administering Linux systems I often find myself struggling to track down the culprit after a partition goes full. I normally use du / | sort -nr but on a large filesystem this takes a long time before any results are returned.  Also, this is usually successful in highlighting the worst offender but I've often found myself resorting to du without the sort in more subtle cases and then had to trawl through the output.  I'd prefer a command line solution which relies on standard Linux commands since I have to administer quite a few systems and installing new software is a hassle (especially when out of disk space!) What happens to matter in a standard model with zero Higgs VEV? How many combinations are possible in the game tic-tac-toe (Noughts and crosses)?  So for example a game which looked like: (with positions 1-9)  A1   --   B1  A2   --   B2  A3   --   --   [1][3][4][6][7] would be one combination When I install a simple program it often uses make &amp;&amp; make install and doesn't often even have an uninstall target.  If I wish to upgrade a program, is it standard protocol to assume it just rewrites seamlessly over the old program?  How do I keep track of these programs; do most people just 'fire and forget' and if no uninstall target is given do I have to manually delete everything? How to find the build / version of Windows 10 During the beta of Windows 10 it was hard know what version you were running unless it had it posted to the desktop. Once that wasn't there - how do you tell what version / build you are running?   This will become more of an issue as Microsoft starts releasing more builds with the new update mechanism. Is it possible to get total render time via Python code when render’s done? What iron-clad reason did Dumbledore have for believing Snape was on his side What iron-clad reason did Dumbledore have for believing Snape was on his side? Maybe he was a good actor and a double agent. Was it just that he loved (or pretended to) Lily or he used legilimency? Remove Indentation for a Single Paragraph Is there a way to remove the indentation at the beginning of a paragraph for a single paragraph.  I know I could do  \setlength{\parindent}{0cm} This is my paragraph.  Blah blah blah. \setlength{\parindent}{default}   Where default is whatever the default indentation is for the document class I am using (part of the problem is that I don't know what this default value is).  I feel as if there should be a better way to accomplish this than by the above method.  I am looking for a solution of the form:  \noindent This is my paragraph.  Blah blah blah.   Is there a way to do this, or will I have to resort to the former method?  If I have to resort to the former method, what is the default indentation value for the amsart document class? Old phone cannot connect to computer, the "computer connection" icon appears on phone I would like to get some pictures and audio out of an AT&amp;T SGH-a687 phone onto my Mac computer. I first tried connecting it to a New PC Studio on a PC, but there was a problem after transfer 2 photos, so I tried again. But the PC could no longer detect the phone, even though the "connected to computer" icon appears on the phone. I tried a different cable, different USB ports. No use.  So I downloaded the Samsung Kies on my Mac. Same thing, it tries to search for the phone once I connect the phone, but the computer doesn't detect anything. The phone still shows the "connected to computer" icon.  There is also Bluetooth (no internet on the phone) on the phone, but it failed to send the picture each time I tried.  What can I do at this point? Please also suggest data extraction software for either Mac or PC, if that's the easier route. I can't install software-center on Kali It is known that a superconductor is a material with electrical resistance zero. My question is, it is exactly zero, a theoretical zero, or for practical realistic reasons it is effectively zero? How to rank a million images with a crowdsourced sort I'd like to rank a collection of landscape images by making a game whereby site visitors can rate them, in order to find out which images people find the  most appealing.  What would be a good method of doing that?   Hot-or-Not style? I.e. show a single image, ask the user to rank it from 1-10. As I see it, this allows me to average the scores, and I would just need to ensure that I get an even distribution of votes across all the images. Fairly simple to implement. Pick A-or-B? I.e. show two images, ask user to pick the better one. This is appealing as there is no numerical ranking, it's just a comparison. But how would I implement it? My first thought was to do it as a quicksort, with the comparison operations being provided by humans, and once completed, simply repeat the sort ad-infinitum.   How would you do it?  If you need numbers, I'm talking about one million images, on a site with 20,000 daily visits. I'd imagine a small proportion might play the game, for the sake of argument, lets say I can generate 2,000 human sort operations a day! It's a non-profit website, and the terminally curious will find it through my profile :) What is the largest inductance value ever attained(in Henries)? What is the number of strings at size $n$ that is constructed from ${a,b,c,d}$ and there is an even num of $a$