Hot answers tagged

24

On a GNU system and if you have pv, you could do: cmd=' that command | to execute && as shell code' yes | pv -qL10 | xargs -n1 -P20 sh -c "$cmd" sh The -P20 is to execute at most 20 $cmd at the same time. -L10 limits the rate to 10 bytes per second, so 5 lines per second. If your $cmds become two slow and causes the 20 limit to be ...


7

The ~ is part of the filename: ls *.py~ Thus, to delete all such files: rm *~


5

Just use sed p. echo foobar | sed p You don't need cat, either: sed p input.txt # or sed p input.txt > output.txt Explanation p is the sed command for "print." Print is also sed's default action. So when you tell sed explicitly to print, the result is that it prints every line twice. Let's say you wanted to only print lines that include the ...


4

Simplistically, if your command lasts less than 1 second you can just start 5 commands each second. Obviously, this is very bursty. while sleep 1 do for i in {1..5} do mycmd & done done If your command might take more than 1 second and you want to spread out the commands you can try while : do for i in {0..4} do sleep ...


4

The entire format string is to be preceded by the +: $ date +"So this is week: %U" So this is week: 19 $ date +"So this is week: %U of %Y" So this is week: 19 of 2016


4

This uses gunzip to unzip all files in a folder and have the ending .out.gz gunzip */*.out.gz This will "loop"* through all folders that have a zipped file in them. Let me add an example: A a.out.gz B b.out.gz C c.out.gz D d.out.gz E e.out Using the command above, a.out.gz b.out.gz c.out.gz d.out.gz will all get unzipped, but it won't touch e.out ...


4

You can either escape the $ sign: rm -r .\$EXTEND or use single quotes: rm -r '.$EXTEND'


4

This feels like your home directory is being automounted on demand. This configuration is most frequently used when there are a number of free access workstations. It allows for backups to be taken of files on the central server, and the workstations can be rebuilt at any time from a standard image that has no need to worry about persistent local file ...


4

It's possible for a user on the system (or a monitoring program that captures ps output) to see the password as a parameter to the groupadd process -- if the user or monitor "happens" to run ps while the groupadd process is running. The risk of that happening is small (the groupadd process will likely finish running fairly quickly), but non-zero. See an ...


3

This is normal. To understand it, let's see how file descriptors work and how they are passed between processes. You mentioned that you are using GLib.spawn_async() to spawn the shell script. That function, presumably, creates a pipe to be used for sending data into the child's stdin (or perhaps you create the pipe yourself and pass it to the function). To ...


3

That happened because the output you produced included codes that your terminal interface interpreted as control codes. This is normally resolved with either reset or stty sane.


3

Bash does not allow parameters in aliases, so you need to define and use a function, e.g.: ylog() { yarn logs -applicationId "${1/#job_/application_}" }


3

.epub files are .zip files containing XHTML and CSS and some other files (including images, various metadata files, and maybe an XML file called toc.ncx containing the table of contents). The following script uses unzip -p to extract toc.ncx to stdout, pipe it through the xml2 command, then sed to extract just the text of each chapter heading. It takes one ...


3

Each line you write must have a command, usually the first word. To get something printed, a common command is echo. If the pwd (present working directory) has files a, aa, bb, and ccc. Then, this command will print all files in the directory: $ echo * a aa bb ccc And this command will print all files in the pwd that have one character: $ echo ? a ...


3

? is a special character in pattern matching, which match any single character. So the command means find all files and directories in /foo/path and its subdirectories, whose names are exactly one character long. The \? is used to prevent your shell from performing filename generation. You can use other quoting mechanisms: find /foo/path -name '?' or: ...


2

It's a kind of necroposting but I've had the same problem recently (with a different backend) and found that the reason is in a wrong Content-Type. By default it's "text/plain" or "text/html", and in my case curl -H "Content-Type: application/json" -d ... solved the issue.


2

You can use screen multiplexer such tmux. It is available via apt-get on ubuntu machines


2

You can use the commande file e,g: file images.jpg the output is something like : images.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 342x147, frames 3 OR rdjpgcom -verbose images.jpg sample output JPEG image is 342w * 147h, 3 color components, 8 bits per sample JPEG process: ...


2

I was able to solve this problem by following commands : mv /var/lib/dpkg/info/coturn.* /tmp/ dpkg --remove --force-remove-reinstreq coturn This worked. And I installed coturn again, then it worked.


2

It looks as though some of your commands have been modified/removed outside of yum. You need to reinstall the missing commands like so: yum reinstall which You can give multiple packages as you identify them: yum reinstall which clear If you find that lots of commands have been removed, it may be easier to reinstall your whole system.


2

With a C program, You can for example use a thread which sleeps for 0.2 seconds into a while #include<stdio.h> #include<string.h> #include<pthread.h> #include<stdlib.h> #include<unistd.h> pthread_t tid; void* doSomeThing() { While(1){ //execute my command sleep(0.2) } } int main(void) { int ...


2

In KDE the reference CD burning software is K3b, which is packaged in Debian as k3b. On the command-line you'd probably use cdrkit (the main package is called wodim).


2

Another common remedy for this problem is to type Ctrl-VCtrl-O at the shell prompt. The first puts the shell into "literal" mode so that it won't modify the following character, which is the terminal reset command understood by almost all common terminal types. You might need to echo this instead, on some terminals.


2

"Going hybrid" with Debian versions is not always worthwhile, (or safe, or reliable, etc.), but sometimes it works. The hybrid version's best case is when a package from testing or unstable makes only trivial changes, (in perpetuity even), and everything works smoothly thereafter. Possibly it's already been packaged in Debian Backports, or some repository ...


2

From the find(1) manpage: The -H, -L and -P options control the treatment of symbolic links. Command-line arguments following these are taken to be names of files or directories to be examined, up to the first argument that begins with -, or the argument ( or !. That argument and any following arguments are taken to ...


2

To differentiate a variable from a string bash uses $. When you do : rm -R .$EXTEND variable $EXTEND is expanded and the result is substituted. Inorder to remove .$EXTEND file you need to tell bash to interpret $ without its special meaning. You can do it two ways : rm -R .\$EXTEND #\ strips the special meaning of $ or rm -R '.$EXTEND' # Use single ...


2

Mathematica is expensive, but there are several free alternatives. See https://en.wikipedia.org/wiki/List_of_computer_algebra_systems - many of these are Free Software with BSD or GPL licenses. If you use Linux, Axiom (or one of its major forks, OpenAxiom), Maxima, and/or Scilab are probably already packaged for whatever Linux distro you use. BTW, ...


2

The easiest and most portable way to see "hidden commands" is probably using cat -v For instance, I might run "cat -v" and paste into that terminal to see the nonprinting characters. Further reading: How can I see what my keyboard sends? (ncurses FAQ)


2

To quote my own post from Meta: Linking to man pages I already have a favored method for this, which you can read about in the less man page in two places: LESS='+/\+cmd' man less and LESS='+/LESS[[:space:]]*Options' man less (See what I did there?)


2

You can use -P flag of man program to use a pager to display pages. For example you can use less as the pager program with flag -p to search for the pattern ERROR happening in the beginning of the line inside the man page: man -P 'less -p ^ERRORS' symlink This opens man page of symlink and jumps directly to the ERRORS section of it.



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