Tag Info

New answers tagged

2

There exists several variants of a watch command, some that spawn a shell to interpret a command line made of the concatenation of the arguments passed to watch (with space characters in between). In those you can do: watch 'ls | shuf' same as: watch ls '|' shuf (those watch actually run: "/bin/sh", ["sh", "-c", "ls | shuf"] and are quite dangerous in ...


2

On a GNU system: find / -type d -print0 | shuf -zn5 | xargs -r0i cp foo {} (now copying the file to things like /sys or /proc would not make sense or even be possible, you may want to add -xdev to only select directories on the file system mounted at /).


0

The commands watch and w have nothing to do with each other other than the first letter being equal. You cannot assume that a parameter for w is equally valid for watch. The watch command takes an integral number of seconds as the value for -n. Incidentally, I've also looked at the man page for w and I can't see any reference to a time period. I'm curious ...


1

In addition to making sure the script is in the $PATH, you also must make the script executable. chmod +x SCRIPTNAME is how you do that.


1

You can check what locations are currently checked for direct commands by looking at the $PATH variable: echo $PATH It's likely this includes /usr/local/bin, in which case you could put a symbolic link there: ln -s /opt/mysuperscript /usr/local/bin/mysuperscript Now you can just type mysuperscript to run your script.


0

You have to install (copy/symbolic link) the script in one of the directories of $PATH or append the script directory to $PATH


2

You don't say what shell are you using. From the behaviour you are describing it's likely zsh. If you have a look in its man page you would notice how redirections are handled. Note that a pipe is an implicit redirection; thus cat bar | sort <foo is equivalent to cat bar foo | sort (note the order of the inputs). Otherwise, regular ...


2

Your understanding is not quite correct. In a | b the stdout output of process a connected through a pipe to stdin of process b. The problem with your code is that with an additional redirection from somefile to process b you will use two different methods at the same time to connect to stdin of process b. Don't do that! The question is; what do you try to ...


1

It is caused by a KDE library adding custom MIME types. Fix it with: sudo mv /usr/share/mime/packages/kde.xml /usr/share/mime/packages/kde.xml.bak sudo update-mime-database /usr/share/mime


0

From the comments and your further investigations it looks like your devtoolset is modifying the PATH. Unfortunately that includes what appears to be an old or broken sudo command. It would be worth trying to modify the devtoolset include in your .bashrc like this, and then logging back in again: if [ "$(gcc -dumpversion)" != "4.7.2" ]; then scl enable ...


0

You can only turn montage shadow on or off (it doesn't accept color, fuzziness & offset). Mogrify supports more shadow options, though... (Thanks don_crissti)


1

I assume that the files under myfiles are not symbolic links, and that none of the file names contain newlines. (My approach can still work if these assumptions are violated but it gets more complicated.) I also assume that you have the common readlink utility and that it supports -f to canonicalize paths, which is the case on Linux (both GNU and BusyBox), ...


4

If I undersood the question correctly you need files in myfiles which do not have symlinks in images: #!/bin/bash OIFS="$IFS" IFS=$'\n' files="$(find myfiles/ -type f -name '*.jpg' -or -name '*.cr2')" for f in $files; do list="$(find -L images/ -xtype l -samefile "$f")" if [[ "$list" == "" ]]; then echo "$f does not have symlink." fi ...


0

I first brought an edit to the question since I thought it was airodump-ng specific, but I actually thought of a generic solution (hence the rollback, my apologies). You could probably use tee here: $ airodump-ng mon0 | tee -a file.log But as far as I can see... Using a standard redirection would also work. $ airodump-ng mon0 >> file.log I tried ...


0

Starting with Mavericks, Apple switched the TLS/SSL engine from OpenSSL to their own Secure Transport engine in Apple distributed curl binary which breaks client certificate usage. Use the curl binary from homebrew.


0

Some sites disable support for SSL 3.0 (possible because of many exploits/vulnerabilities), so it's possible to force specific SSL version by either -2/--sslv2 or -3/--sslv3. Also -L is worth a try if requested page has moved to a different location. In my case it was a curl bug, so curl needed to be upgraded to the latest version (>7.40) and it worked ...


2

There is no stand-alone read command: instead, it is a shell built-in, and as such is documented in the man page for bash: read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] [...] -r Backslash does not act as an escape character. The back‐ slash is considered to be part ...


2

You should be able to use libreoffice in batch mode from the command line e.g. libreoffice --headless --convert-to doc *.odt or libreoffice --headless --convert-to docx *.odt


2

I'd use this kind of construct as a starting point find / -type d -print0 | xargs -0 -I'{}' sh -c 'ls -ltr {} | tail -1' Caveat: it doesn't like empty directories (total 0 is output).


2

Probably this would be better: combination of find and shell find / -type d -print0 | while read -r -d '' dir; do ls -ltr "$dir" | sed '$!d' done find will output each directory found, using the null byte instead of a newline to separate them. This stream is fed into a while loop, using read -d '' to extract each null-delimited directory name. Then, ...


1

Since you asked about sed specifically, ls -ltr | sed '$!d'


1

With awk: ls -ltr | awk 'END { print }'


3

You're looking for tail : ls -ltr | tail -n 1 This will display only the last line of ls -ltr's output. You can control the number of lines by changing the value after -n; if you omit -n 1 entirely you'll get ten lines.


0

You may also use the following syntax: ssh-agent sh -c 'ssh-add && echo Do some stuff here.'


0

The right thing so use is process substitution. wkhtmltopdf --title "$SUBJECT" -q <(command_with_output_stream) $OUTPUTFILE


1

I really dislike unexplained {} and \ markup and don't care much for the ; either! In the alternative, if the {} and \; are overly troublesome, there is an alternative approach. In addition, this approach handles spaces in the file name better than the find ... -exec formulation. find . -type d -print0 | xargs -0 chmod MASK find . -type f -print0 | ...


1

No, here is the output: curl -Ls 'http://pastebin.com/raw.php?i=r2jYDZaw' jQuery(document).ready(function(){ //Check to see if the window is top if not then display button jQuery(window).scroll(function(){ if (jQuery(this).scrollTop() > 100) { jQuery('.scrollToTop').fadeIn(); } else { ...


0

guessing from comment, you seems to be able to do it with a temporary file, why not make a named pipe ? mknod magritte p inside you php code, just write to magritte. wkhtmltopdf should be run with /usr/local/bin/wkhtmltopdf --title "$SUBJECT" -q magritte $OUTPUTFILE you might specify the location more accurately. Still guessing, wkhtmltopdf is run ...


0

to make a program that opens a file by name read from the pipeline give it the special device name /dev/stdin ... for example: /usr/local/bin/program-to-output-the-html | /usr/local/bin/wkhtmltopdf --title "$SUBJECT" -q /dev/stdin $OUTPUTFILE or do this before the command you showed: SOURCEFILE=/dev/stdin then the program will open("/dev/stdin",...) ...


1

You should be able to do this using /dev/stdin and PHP's proc_open(). Start the process with a command such as wkhtmltopdf --title "$SUBJECT" -q /dev/stdin $OUTPUTFILE and pipe the HTML you've got in your variable into the running process.


1

There was no alternative as mintUpdate.py was GUI (gtk) only until I decided to write one. I described it in my blog - Linux Mint Update CLI You can find there link to gitHub as well. I will publish some screenshots as well.


0

While you can always factor out declarations for [io]base= based on the current input radix, another thing you might do is use the explicit hex notation, which should work regardless of input base. Like this: printf %s\\n ibase=2 obase=F 1001 | bc ...which prints... 9 You might find this can be especially useful if you ever get lost when setting input ...


8

If you want to crawl on dirs and subdirs: find /home/place/to/crawl -type f -exec file --mime-type {} \; | awk '{if ($NF == "image/jpeg") print $0 }' What it does? Search all inodes with the type file Execute the command file, to get a jpeg header of the file like: image/jpeg awk Edit: Added @Franklin tip, to use file with -i to use the mime string ...


2

Because you are setting the input base first, then when you set the output base, the 16 will be interpreted according to the input base (2). It appears that the 6 in 16 is simply interpreted is a binary 1 bit in this case, and so the output base gets set to binary 11 or decimal 3. To work around this, you can set the output base before you set the input ...


2

Because you set ibase=2 first, you need to use obase=10000: $ echo 'ibase=2; obase=10000; 1001' | bc 9


0

grep -r --include "httpd.conf" "10.22.0.141" . | cut -d: -f3- |\ cut -d ' ' -f4 | sort | uniq -c


-1

You can use echo -e, it understands escape sequence \n, \t: echo -e "first line\nsecond line\nthirdline" > foo


0

To create a list of new or modified files programmatically the best solution I could come up with is using rsync, sort, and uniq: (rsync -rcn --out-format="%n" old/ new/ && rsync -rcn --out-format="%n" new/ old/) | sort | uniq Let me explain with this example: we want to compare two dokuwiki releases to see which files were changed and which ones ...


1

The limitation you mentioned is generally about the exec buffer used, not specific to individual commands. The purpose of xargs is exactly to address that problem; xargs will take as many arguments as possible to feed the command. This will get you the least command calls and thus good performance. Reducing the amount of arguments for the command by ...


3

You will need to store the output in a variable to accomplish this. Here is an example: if output=$(cmda); then printf '%s' "$output" | cmdb fi


1

exec here could be a system call or a bash built-in or something else from this . And respective man pages related to system call or bash built-in refer to the exec's man page with numbers in the brackets. So if I want to refer to manpage of bash built-in, I would say exec(1) and if I want to refer to manpage of system call exec() i would say exec(2) The ...


3

These numbers disambiguate manual pages that have the same name. They represent the manual section that the page should be retrieved from. As an excerpt from Wikipedia states: The manual is generally split into eight numbered sections, organized as follows [...]


1

The numbers are the sections in the manual. (1), for example, are commands.


3

In the first line, xargs still waits for the second argument or an end of the input. After pressing Ctrl-D xargs continues with the rest and you will see the 5th x as single argument. This example may explain the behavior: (echo "x x x x x"; sleep 5; echo "x") | xargs -n2 Output: x x x x x x # after 5 seconds After the 6th x in the second echo ...


1

Some shells don't flush the current shell's history to .bash_profile until the shell exits. There are commands to flush it without exiting, I don't remember them off the top of my head.


3

date is separate from your shell, so unless you instruct your shell to modify the environment date sees, your changes to LC_TIME won't have any effect. You can fix this in two ways; either by specifying a value for LC_TIME only for date: LC_TIME=zh_CN.UTF-8 date or by exporting LC_TIME so its new value is given to all subsequent processes started by the ...


0

Here is my solution which is shorter in code and works fine for other dates than the current month. Sorry for the US people, this uses ISO format, i.e. 1st day of week is monday. This is done with the -m option for cal and the %V option for date #!/bin/bash if [ "$1" = "" ] then when="now" else when="$1" fi y=$(date --date "$when" +%Y ) if [ $? -ne 0 ] ...


0

Putty works well on Linux and offers some convenience, especially for serial communications. It has one drawback I haven't been able to directly solve: no copy-paste from the Putty window itself. The windows version has a lovely auto-copy to clipboard on highlight, right-click to paste behaviour (and there are excellent plugins for both chrome and firefox ...


0

ls doesn't do this. Its job is to report on file metadata (permissions, timestamp, etc.), not on file contents. But file itself does (combined with a shell wildcard to list all files): file * for the current directory, or file /some/directory/* in another directory. If you want to combine metadata and file content information, you can combine the ...


3

ls itself won't show this information. You can pipe the output of the find to file -f -, as follows: $ find /usr/local/bin | file -f - /usr/local/bin: directory /usr/local/bin/apt: Python script, ASCII text executable /usr/local/bin/mint-md5sum: ASCII text /usr/local/bin/search: ...



Top 50 recent answers are included