I have a function which is meant to keep a record of every program I've installed (really, I'm interested in keeping track of dependencies). I've tested out my command in a terminal and it works just fine:  dnf install sc | tee -a ~/Scripts/dnf_install.log  Note that sc is just the program I chose since I happened to want to test out a few spreadsheet programs (without bloating my computer with unremoved dependencies) and it's got a short name.  Anyway, so I want to make this a function so I put in my .bashrc the following:  # easier install with logging function install () {     dnf install $1 | tee -a ~/Scripts/dnf_install.log }   However, I always get this error:  ryan: ~ $ sudo install sc [sudo] password for ryan: install: missing destination file operand after ‘sc’ Try 'install --help' for more information.   After trying to narrow things down a bit, I'm pretty sure that the offending part of the code is dnf install $1 and not the part afterwards.  Can anyone explain to me what I'm screwing up and how/why the command is being treated differently inside a function than directly inputted?  Edit: issue solved. As don_crissti pointed out, "sudo forks/execs a new shell that doesn't know about your function." So I put sudo inside the function and also changed $1 to "$1" for good coding practice. I did not know this was a duplicate since I didn't know the issue had to do with sudo.
I have a script that does a number of different things, most of which do not require any special privileges. However, one specific section, which I have contained within a function, needs root privileges.  I don't wish to require the entire script to run as root, and I want to be able to call this function, with root privileges, from within the script. Prompting for a password if necessary isn't an issue since it is mostly interactive anyway. However, when I try to use sudo functionx, I get:  sudo: functionx: command not found   As I expected, export didn't make a difference. I'd like to be able to execute the function directly in the script rather than breaking it out and executing it as a separate script for a number of reasons.  Is there some way I can make my function "visible" to sudo without extracting it, finding the appropriate directory, and then executing it as a stand-alone script?  The function is about a page long itself and contains multiple strings, some double-quoted and some single-quoted. It is also dependent upon a menu function defined elsewhere in the main script.  I would only expect someone with sudo ANY to be able to run the function, as one of the things it does is change passwords.
What's the problem with my Young slits experiment? My Young's slits experiment doesn’t work. I mean I tried to see wave effect of light but I didn’t see any thing expect particles! I’ve sent you a pic of my laser and a short video of the experiment. Is there any problem you think? bash dynamic (variable) variable names home socket with DC voltage I'm wondering why, in a standard house, instead of using many low power AC-DC rectifier, there isn't a big (like 12V 20~50A) AC-DC rectifier which supplies some wall socket with a DC voltage? In the long run this should be less expensive, given the fact that AC to DC in one big apparatus is done better than in many low-quality transformers, right?  Also, modern chip DC voltage regulators have efficiency of >90%, so smaller (or even larger) voltages are still efficient and possible.  So we could use a 12V socket to charge a phone, desktop computer, laptop, radio etc... and still have an AC socket to move washing machine engine and other things that work better with an AC supply.  Why isn't this done?  edit: real question is: is it convenient, given a standard family (2 laptop, 1 desktop, 4 smarthpone, 1 big tv and some minor electonic) to do so? Clocks for multiple timezones in GNOME Shell I looked everywhere but I couldn't find a way to display multiple clocks in GNOME 3. In classic GNOME and Unity, it is possible. Also, for some strange reason, additional timezones cannot be added to the clock using the time-date applet in classic GNOME. Any solutions? Can I use my Schengen visa for a completely different purpose and entry point? How to directly prove that $M$ is maximal ideal of $A$ iff $A/M$ is a field? An ideal $M$ of a commutative ring $A$ (with unity) is maximal iff $A/M$ is a field.  This is easy with the correspondence of ideals of $A/I$ with ideals of $A$ containing $I$, but how can you prove it directly?  Take $x + M \in A/M$.  How can you construct $y + M \in A/M$ such that $xy - 1 \in M$?  All I can deduce from the maximality of $M$ is that $(M,x) = A$. What does it mean to "program to an interface"? How can I move an installed game from one Steam library folder to another? I use (and have it much bigger) drive D: to store all my user data and games, but I have installed the Steam client on drive C:. When I was installing a first game (Warhammer 40000), I've chosen to place my library folder on drive D: and the game went there.  But now as I've got installed the second game (Portal), I can see that it was put on drive C: despite to the choice I've done previously. When I open Steam - Settings - Downloads + Cloud - Steam library folders, I can see both installation places in the list. Can I merge them into one?  I would even agree to use the default drive C: library (as I've replaced it with a symlink already). When I press to remove one library it says it can only remove empty ones. Multiple TikZ keys with foreach Can you get a Windows (AD) username in PHP? I have a PHP web application on an intranet that can extract the IP and host name of the current user on that page, but I was wondering if there is a way to get/extract their Active Directory/Windows username as well. Is this possible? On my MacBook Pro I have found that several applications seem to share the value for a find.  For example, I searched 'applestackexchange' in Safari's unified address bar, then I switch to Xcode and click into a Find field.  The first word of my search in Safari then appears there.  iTerm2 and Sublime Text 2 also seem to participate in this sharing.  Running latest Mountain Lion on  a 2012 MBP. How can I create an Excel spreadsheet with C# without requiring Excel to be installed on the machine that's running the code? Is there a way in javascript to detect if the unload event is caused via a refresh, the back button, or closing the browser? My intent is to show that a composition of bijections is also a bijection by showing the existence of an inverse.  But my approach requires the associativity of function composition.  Let $f:  X \rightarrow Y, g:  Y \rightarrow Z, h:  Z \rightarrow W$ be functions.  $((f \circ g) \circ h)(x) = h((f \circ g)(x)) = h(g(f(x)))$, and $(f \circ (g \circ h))(x) = (g \circ h)(f(x)) = h(g(f(x)))$.  However, I am having problems in justifying that the two compositions, $(f \circ g) \circ h$ and $f \circ (g \circ h)$, have the same domain and range.  When I consulted ProofWiki, whose link is at the bottom, I got even more confused.  Specifically, for $(f \circ g) \circ h = f \circ (g \circ h)$ to be defined, ProofWiki requires that dom$g =$ codom$f$ and dom$h =$ codom$g$.  First of all, I think that it should be dom$g =$ range$f$ ....  Moreover, as you can see in the example below, you actually have to adjust domains and ranges of $f, g, h$ for the requirement to hold true.  Let $f: \mathbb R \rightarrow \mathbb R$ be $f(x) = 2x$, $g: \mathbb R^+ \rightarrow \mathbb R$ be $g(y) = ln(y)$, $h: \mathbb R \rightarrow \mathbb R$ be $h(z) = z - 10$.   Then $((f \circ g) \circ h)(x) = ln(2x) - 10 = (f \circ (g \circ h))(x)$, with dom$((f \circ g) \circ h) = \mathbb R^+$ = dom$(f \circ (g \circ h))$.  As a result, we need to set dom$f = \mathbb R^+$, range$f = \mathbb R^+$; dom$g$, range$g$, dom$h$, and range$h$ remain the same.  Am I allowed to do that?  This adjustment implies that when we say dom$f = X$, $f$ must be defined for all elements in $X$, but $X$ may not be the entire set of elements for which $f$ is defined. My windows directory is huge Both are in the present perfect, but one uses the verb 'to go' and the other 'to be'. Is there a rule for this?  Is there any chance that the differences between "I have been" vs. "I have gone", are differences in English dialect (I don't know if this is the right word).  Edit Could I say that North American English speakers use "I have gone", and maybe U.K speakers say "I've been"? Or vice versa. Expected Value of the maximum of two exponentially distributed random variables I want to find the expected value of $\text{max}\{X,Y\}$ where $X$ ist $\text{exp}(\lambda)$-distributed and $Y$ ist $\text{exp}(\eta)$-distributed. X and Y are independent. I figured out how to do this for the minimum of $n$ variables, but i struggle with doing it for 2 with the maximum.  (The context in which this was given is waiting for the later of two trains, with their arrival times being exp-distributed).  Thanks! If the lines intersect the vertices of the square. The area of the square is $1$ and the lines also intersect the midpoints of the square lines. How to find the area of shaded region? Is it safe to delete from C:\Windows\Installer? I've been looking on an XP machine what is using all that diskspace, and it turns out C:\Windows\Installer is high up there on the list of directories that use the most diskspace.  It seems to contain a cache of msi and msp files.  Is it safe to delete those? To save diskspace, I've been deleting the "$KB...$" directories for ages without any problems. I want my Windows Updates in my system, why you would want to uninstall them is something that I have never understood. (Except when you're on an update revision board professionally or something of that order.) I extracted simple example:  require 'pp' x = 1..3 pp x.map do |i| {:value =&gt; i, :double =&gt; (i*2)} end pp x.map { |i| {:value =&gt; i, :double =&gt; (i*2)} }  pp(x.map do |i| {:value =&gt; i, :double =&gt; (i*2)} end) pp(x.map { |i| {:value =&gt; i, :double =&gt; (i*2)} })   I am wondering why first pp produces:  [1, 2, 3]   While all the oders are giving:  [{:value=&gt;1, :double=&gt;2}, {:value=&gt;2, :double=&gt;4}, {:value=&gt;3, :double=&gt;6}]   I assume it has something to do with operator precedence. Where can I find good explanation?