Hot answers tagged

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

.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

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 ...


2

I would recommend putting those commands into a script that you remotely call with ssh. Otherwise you'd need to put the whole "remote" part of the command line into quotes and properly escape everything inside. This can be tedious and error prone. That's why remote script call.


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

When you use grep with color options it produces extra escape character sequences which tell the terminal to turn color on or off, these sequences introduce a risk of not being interpreted properly and causing unexpected results. You can view these by capturing grep's output With no color send greps output to output.txt % grep -o --color=none '.\+ middle ...


2

Try: cp /usr/share/backgrounds/*.jpg /week/pictures/final/jpg/ 2> cp.err Note that the cp.err file will be created in the directory where you are when you run the command. If you want the error file in a differente directory, you can do: cp /usr/share/backgrounds/*.jpg /week/pictures/final/jpg/ 2> /desired_directory/cp.err


2

Looking in /media is a reasonable way to find hotplug block devices. You can also use lsblk to list the block devices and whether they are hotpluggable: $ lsblk -l -p -o name,rm,hotplug,mountpoint NAME RM HOTPLUG MOUNTPOINT /dev/sda 0 0 /dev/sda1 0 0 / /dev/sda2 0 0 [SWAP] /dev/sda3 0 0 /home /dev/sdc 0 1 ...


2

It might be easier to simplify the command so that you have fewer special characters on which the shell might choke: ssh jboss@myTargetServer 'ps -p $(cat /var/run/jboss-as/jboss-as-standalone8.pid) -o %cpu= 2>/dev/null' The trailing 2>/dev/null throws away the error text in the event that the PID file either cannot be found or contains a stale PID. ...


1

I would put environment variables in .bash_login or .bash_profile, since they are (when exported) inherited to subshells and don't need to be reset for every shell invocation. Not that resetting them would cost practically anything, but in case I want to set an envvar to something else for the duration of a subshell. That's hard to do if the .bashrc ...


1

Since the question is essentially asking for opinions, you will get different answers. A good design practice, for example, uses as few places as possible to provide a given feature. Some put information like this in the system area to reduce the amount of work done by users to customize their shell environment. In my environment, I use the terminal ...


1

I put PS1 code in bashrc all the time. My code is as follows: export PS1="\[\e[01;37m\][\[\e[0m\]\[\e[01;32m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[01;34m\]\h\[\e[0m\]\[\e[00;37m\] \[\e[0m\]\[\e[00;37m\]\t\[\e[0m\]\[\e[01;37m\] \W \e[1;37m(\e[1;32m|\e[1;33m|\e[1;31m|\e[1;37m]\\$ \[\e[0m\]" I use a different PS1 for root (/root/.bashrc) - red username, ...


1

The second command as you have it runs the code part ($()) in local subshell. You need to make it run on the other side by escaping special characters (basically $): ssh jboss@myTargetServer tmpValue=\$(cat /var/run/jboss-as/jboss-as-standalone8.pid) \ && top -b -U jboss -n 1 |grep \$tmpValue |awk '{print $9}' or put it all into the apostrophes ' ...


1

One way with find and install: find /var/public/voicelogging/quality_monitoring -name \*.WAV -exec sh -c ' bn=${0##*/}; x=${bn%%-*}; dt=${x##*_}; y=${bn%_*}; id=${y##*_} install -D "$0" "/home/username/logging/${id}/${dt}/${bn}"' {} \; this uses parameter expansion to extract the date: ${dt} and the user id: ${id} from the filename and then uses install ...


1

The df is reporting a small number because you're mostly deleting directories, which are relatively small. Also, depending on the filesystem, changes to directories and changes to the number of links to a file are journaled and/or synced to the disk immediately, since they're critical for fault recovery, and thus slower. That's actually a testament to the ...


1

Try to use find command : find /usr/share/backgrounds -iname "*.jpg" -type f -exec /bin/cp {} /week/pictures/final/jpg 2>cp.err \;


1

You are receiving that error because the program "update_prebinding" is not in your PATH, possibly because it is not installed on your system.


1

All of the above examples will tell you the size of the data on disk (i.e. the amount of disk space a particular file is using, which is usually larger than the actual file size). There are some situations where these will not give you an accurate report, if the data is not actually stored on this particular disk and only inode references exist. In your ...


1

If you see a mismatch between what df and dh report, you may have open files which are deleted but are still being written to. This takes up disk space (according to df), but is not reported anywhere (such as du) because the space doesn't belong to any existing file. If you experience this, you may need to restart some services (or the machine for a brute ...



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