Tag Info

New answers tagged

0

Command line arguments like *.txt are interpreted by the shell before being passed to the script/program. In the case that you have no files matching that pattern, nothing special happens but when that pattern is matched and expanded, you have problems (as you've noted). The solution is to quote your command line arguments, e.g. use "*.txt" instead of ...


0

"-a" Attach a file to your message using MIME. When attaching single or multiple files, separating filenames and recipient addresses with "--" is mandatory, e.g. mutt -a image.jpg -- addr1 or mutt -a img.jpg *.png -- addr1 addr2. The -a option must be placed at the end of command line options. –


0

Try ex-way: ex -s +'v/\S/d' -cwq test.txt For multiple files (edit in-place): ex -s +'bufdo!v/\S/d' -cxa *.txt Without modifying the file (just print on the standard output): cat test.txt | ex -s +'v/\S/d' +%p +q! /dev/stdin


0

I gave a try to lftp: lftp -c "torrent $1" where $1 is the .torrent file. Unlike lftp -e "torrent $1" lftp -c must exit when the command is done (lftp -e leaves you in its command pronpt). It also does seeding. (I don't know yet how seeding interacts with -c.)


2

You can also try rtorrent and may be ctorrent which man page starts with: ctorrent - Download bittorrent files from command line


5

Check out transmission-cli. The usage is as simple as running transmission-cli <torrent-file>, but you can obviously tune it to your needs with several options. Just a side comment: Actually you could use many other options, apart from transmission-cli and there will probably appear many other suggestions here (like deluge by Benjamin B. in the ...


0

I have a solution in bash. You need a function that is exectued before every command. Since bash doesn't support that natively you have to work around that using the DEBUG trap. See the bash's manual page part of the DEBUG trap: If a sigspec is DEBUG, the command arg is executed before every simple command, for command, case command, select ...


0

You can use setsebool httpd_can_network_connect=1


1

@dhag certainly has a one-line answer, but the syntax makes my eyes hurt. :) Since you asked for a single command, and since the shell considers for-do-done a single (compound) command, I feel justified with this much more readable version: for i in {1..10}; do yes &; done Note that some shells automatically nice(2) background jobs, so if that's an ...


3

Would something like the following be OK? This assumes bash (for brace expansion) and GNU parallel. parallel -j 256 -u yes \; : {} ::: {1..10} The -j 256 setting is there to make sure as many processes as parameters get started, up to a limit of 256, and -u (ungroup) is there so that the output of each process is printed as soon as it is available (this ...


0

Like @Gilles said, the display manager will start your desktop environment. According to the Debian Wiki, mostly these end with dm, only exception is slim. So this should suffice for most of people's needs: ps auxf | awk '{print $11}' | \grep --color -e dm$ -e slim$ Or to be sure, it exists as a parent process, and is not forked (except from the init ...


3

Here's a conceptual approach that might work. The alias command generates a list of all aliases, each followed by an = and it's definition. This output could be parsed by extracting the alias name from between the first blank and the first =. Everything after the first = would be the definition to be matched against. This sounds like something easily ...


1

find is rarely useful when you don't need to traverse a directory tree recursively. Here a simple loop and shell wildcards are enough. for x in */161901.pdf; do mv -- "$x" "xyz/${x%/*}.pdf" done Or, with the Perl-based rename command on Debian, Ubuntu and derivatives (prename on Arch, not the Linux rename command on other distributiosn): rename ...


0

You can possibly use PolicyKit rules to "unlock" libvirt for uids which are members of a specific gid-group. Here is another question, which does that for virt-manager (which like virsh console is based on libvirt). http://superuser.com/questions/548433/how-do-i-prevent-virt-manager-from-asking-for-the-root-password Specific advice for "unlocking" virsh ...


1

Yes. This is easy. Install the system with the GUI libraries for X (drivers optional) and for the desktop environment you want. Then, run something like the TigerVNC server, and you're done.


0

Something that I do and it works for my purposes is ls /home Granted, that doesn't really give you a list of users rather a list of user's home directories and past user's directories but any command you want to do on a user that doesn't exist terminal will tell you and could be a hint to remove the home file that doesn't have a user or move it!


1

The single most important advantage of CLI over GUI is that with a CLI you can easily connect a command's output to another command's input. This connection has a simple and intuitive notation (a pipe, |), and its implementation is highly efficient. This allows one to solve complex tasks by chaining together very simple building blocks. For example, this ...


6

Try: cat /sys/class/net/eth0/speed I'm not sure what you mean by primary interface. On a host with an IPv4 stack, you could retrieve the interface where the first default route is with: ip route show 0/0 | grep -Pom1 'dev +\K[^ ]+' (assuming GNU grep). So: cat "/sys/class/net/$(ip route show 0/0 | grep -Pom1 'dev +\K[^ ]+')/speed" Not all IPv4 ...


5

It's all about metaphors for communication. GUIs are picture books - they let you move things to other things, or right click on things and select options. But you still type a post when you want to ask a question. Command lines are much the same thing - they're about telling a computer what to do. If what you're trying to do is simple, then pictures and ...


0

I think it can helps you : #!/bin/bash declare arr=('bigdeal777', 'Goog1e_analist_certs.*', 'tevq\(ucyq\)', 'GR_HOST_ID.*', "\['cmd'\]", 'ejppy.*', 'eval\(gzinflate.*', 'eval\(base64_decode*.', 'FilesMan*.', 'Web Shell by.*', 'Goog1e_analist_up.*', 'palcastle.*', 'shell_exec', 'google_analytics_obh.*', ...


1

If you can put those in a file you can use grep's -f flag to read the patterns from a file and you can use -l to show just the files that have a match Putting those together you can do something like grep -R -l -f scanner.txt * So the -R will cause it to search recursively (I'm assuming you want that), -l will print just the names of the files that ...


0

This will do the trick: # cp /etc/xdg/xfce4/xinitrc /home/user/.config/xfce4/xinitrc # chown user /home/user/.config/xfce4/xinitrc # chown user /home/user/.ICEauthority $ startxfce4


0

Later I found while read -r line very helpful and I've succeed with following command:- find -name 161901.pdf | while read -r line; do mv $line ./xyz/$(echo $line | cut -d "/" -f 2).pdf; done Explanation:- Here find -name 161901.pdf list the founded files (already mentioned in question) which piped to while loop in while path stored in variable line. ...


5

The standard (POSIX) syntax is: kill -s STOP "$pid" That is, without the SIG prefix. Some shell implementations, support kill -s SIGSTOP or kill -SIGSTOP as an extension but that's not standard nor portable. The Unix specification (POSIX+XSI) also allows: kill -STOP "$pid" And kill -19 "$pid" Though which signal number is SIGSTOP is not specified ...


1

To start with: SIGSTOP will temporarily stop the process but keep in memory so it can be continued later on using SIGCONT system call. You can use the following little snippet to see what happens #!/bin/bash set -x sleep 100 & pid=$! kill -s SIGSTOP "$pid" sleep 2 kill -s SIGCONT "$pid" You'll see what the script does interactively. So to get ...


0

If you have rename / prename command find -name 161901.pdf -exec prename -n 's!/!-!g; s!\W*!xyz/!' {} + and remove -n if you like what you see. (Larry Wall and Robin Barker' prename is installed with perl.deb package; Brian d Foy Unicode::Tussle rename also works)


1

In complement to @apaul, I emphasize that compressing files individually bzip2 *.log.* (replace bzip2 by gzip, xz, or what ever your favorite file zip is) may be important: This way you can still see (bzcat file.bz2), search (bzgrep file.bz2), edit (vi file.bz2) the compressed file and remove the older ones when necessary.


1

In Linux you can use free to see the amount of memory used. Using free before and after a process was executed you might be able to see if all memory is released. Keep in mind though that other applications might have allocated or released memory in the mean time. If you want to monitor a process while it is allocating and/or releasing memory try pmap -x ...


5

I figured out a tar solution by myself. It deletes single file after compressed it into the target file. The compressing speed is not quite fast, though. The command looks like: tar -zcvf my_log.tar.gz *.log --remove-files


9

gzip or bzip2 will compress the file and remove the non-compressed one automatically (this is their default behaviour). However, keep in mind that while the compressing process, both files will exists. If you want to compress log files (ie: files containing text), you may prefer bzip2, since it has a better ratio for text files. bzip2 -9 myfile # ...


0

Sweet and simple: #!/bin/bash find . -name 161901.pdf | while read -r line do # this will create new filenames e.g. ./May-2013/161901.pdf will be now May-2013-161901.pdf filename=$(echo $line | grep -oP "\/\K.+$" | sed 's/\//-/g') # now just move the files mv $line xyz/$filename done So, essentially it's just a 2-step process. Create new ...


0

This could be a possible solution. The argument of the script is the directory in which you are searching, and now it is just printing what will do: #!/bin/bash find "$1" -type f -name '161901.pdf' -print0 | while IFS= read -r -d '' f do # get folder name d="$(basename "${f%/*}")" target="${d}.pdf" echo cp $f "xyz/${target}" done


1

One way is to use find -print and pipe the filelist to awk where you can transform it to whatever you want, e.g. a cp command: $ find -name 161901.pdf -print | awk -v TARGET=xyz -F'/' '{ printf "cp %s %s/%s.pdf\n", $0, TARGET, $2; }' cp ./May-June-2011/161901.pdf xyz/May-June-2011.pdf cp ./Nov-Dec-2011/161901.pdf xyz/Nov-Dec-2011.pdf and this can then be ...


3

Perl module Unicode::Tussle comes with a very useful script named rename (which is unfortunate, because the name clashes with the standard rename(1) on Linux). With it, you could do something like this: mkdir xyz find . -name '*.pdf' -print0 | \ rename -0 's!^\.!xyz!; s!/[^/]*\.pdf$!.pdf!' Without Perl, you could still do the same thing with a bit ...


6

# ./run > /dev/null This redirects stdout to /dev/null, but it doesn't do anything at all with stderr. Since you asked to redirect form stdout and stderr, this does not do what you want. # ./run > /dev/null 1>&2 This redirects tdout to /dev/null, and then it redirects stdout again (1>) to wherever stderr points to (&2) which is ...


1

To print only users that have no login shell you can use awk only in it's simplest case: awk -F/ '$NF != "nologin"' /etc/passwd Here we use -F/ as delimiter and then '$NF =! "nologin"' where$NFis the last field of the line/row. The default action inawk` is print so it'll print the whole line. Finding all files starting with an s can easily be done using ...


0

First: grep -v "/sbin/nologin$" /etc/passwd | cut -d: -f1 Second: ls -ld /etc/s* | wc -l


0

1. grep -v '/sbin/nologin' /etc/passwd|awk -F: '{print $1}' 2. ls s*|wc -w Or better: 2. ls -l s*|wc -l to avoid error when you have filename with space(s)


0

The thing is not delimiter but in words symbols which can be alphabet symbols, digit or underline only so any which is not from list count as delimiter.


0

Also to see the files in a specific directory sorted by size after you have found the directory using du use: ls -lrSh


1

The programs you're having trouble with are all run using the dev-lang/python-exec script wrapper, which appears to have been somehow corrupt. To attempt to re-install that package, assuming nothing else was severely harmed, you can try (adjust the version number to match your installed packages): /usr/bin/python2.7 /usr/lib/python-exec/python2.7/emerge ...


0

Here's another great option: Instructions here: http://kbeezie.com/geoiplookup-command-line/ for example, on Centos: #yum install GeoIP GeoIP-data #geoiplookup 8.8.4.4 Works perfectly. And of course, you can always set this up as a cron: #/usr/bin/geoipupdate


3

You can use this if you are on a little endian system: iconv -f utf-8 -t ucs-4le | od -tx4 or this if you are on a big endian system: iconv -f utf-8 -t ucs-4be | od -tx4


0

I think beets is what you're looking for. It is very flexible and it can automatically change tags to what it thinks is best, with your permission of course, it uses musicbrainz as a backend. Beets


0

The pipe symbol | connects output from the process on its left to the input for the process on its right. It's a fundamental part of the Unix/Linux ecosystem as it allows you to build up complex operations using relatively simple (and specialist) tools. In case it gives you a reference point, this is similar for Windows systems too, whether Powershell or ...


2

Looks like my manpage of fallocate(1) command line tool is out of date. There is the appropriate option --punch-hole (-p): fallocate -p -o 10G -l 1G qqq


1

using find to find all files you want to rename and running an exec script: ` find /main/rel -name file.log -exec mv '{}' '{}.OLD' \; this will run the mv cmd on all found files, the {} (escaped so the shell doesn't do weird things) will be replaced by the filename. this allows you to easily add extra characters to the original filename (e.g. append ...


-1

It is sometimes useful to use -print explicitly when you are performing another action so the filename is displayed as that action is performed. find . -print -delete would be similar to rm -rfv * where -print corresponds to -v. If you don't include -print then the filenames aren't displayed. In order to make the rm command even more similar, by the ...


0

You can use alias for that. From man sh: Aliases An alias is a name and corresponding value set using the alias(1) builtin command. Whenever a reserved word may occur (see above), and after checking for reserved words, the shell checks the word to see if it matches an alias. If it does, it replaces it in the input stream with its ...


1

For many years the find command did not have a default action. A common error was forgetting to add the -print option to your find command. I still to this day type it out of habit. But at some point it was added as the default action so now find . and find . -print are equivalent.



Top 50 recent answers are included