Tag Info

Hot answers tagged

9

Sometimes an alias isn't powerful enough to easily do what you want, so here's a way without using them. In some file that is sourced when your shell starts (e.g. .bashrc), add the following function: ls () { echo "Hello world!" command ls } Unlike an alias, a function can recurse. That's why command ls is used instead of ls; it tells your shell ...


8

You must not forget to call ls: alias ls='echo "Hello World!"; ls'


6

advanced cp cp -r /home/username/A/. /usr/lib/B/ This is especially great because it works no matter whether the target directory already exists. shell globbing If there are not too many objects in the directory then you can use shell globbing: mkdir -p /usr/lib/B/ shopt -s dotglob cp -r /home/username/A/* /usr/lib/B/ rsync rsync -a ...


4

Quotes (either single or double) around an argument inhibit glob expansion. Your first example passes a Regular Expression as an argument to grep. Your second example contains a glob pattern which the shell itself expands, passing filenames that fit that pattern as arguments to grep.


3

You could use nohup combined with &: nohup cf logs broker-analytics > /var/www/cfbrokerlogs/message.log & The nohup command causes the program to ignore hangup signals (i.e. those that are sent when closing the terminal), and the & of course runs it in the background. If you want to make sure it's still running or kill it, you can use ps: ...


3

Here it is as one command: echo $(( (2147483633 - $(grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$') )/5184000 )) How the simplification was done First consider this pipeline: cat /proc/zem0 |grep -i isrs` This can be simplified to: grep -i isrs /proc/zem0 Thus, the whole of the first command becomes: grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$' ...


3

Not the issue of ls. It's how symlinks work. The .. gets you into the parent of the current directory, the directory doesn't know you got to it through a symlink. The shell has to intervene to prevent this behaviour. For the shell builtin cd, there is special handling that doesn't just call chdir but memorizes the full directory path and tries to figure out ...


3

If on a GNU system, from man cp: -T, --no-target-directory treat DEST as a normal file This allows you to write cp -rT /home/username/A/ /usr/lib/B/ to do exactly the right thing.


3

Compare also: echo '.*[s]' file with echo .*[s] file This outputs the arguments as seen by the command. In your first example you pass your grep command exactly two arguments: the pattern and the file. In your second example your shell will handle the first argument and replace it with all the files starting with a dot and ending in "s". Therefore ...


3

You have a terminal (or terminal emulator) which understands multibyte encodings (probably UTF-8), but a shell which doesn't. Try setting the environment variable LANG to C.UTF-8. Or run locale -a to find another likely value to try.


2

Function keys can be interpreted by the window manager or terminal emulator (you'll find that F11, for example, will usually maximize the window) or passed through to the program as VTxxx or ANSI escape sequences. F9 on Linux and Solaris usually sends ESC[20~. Depending on the versions of the software, bash or ksh will interpret this as either 0~ or ~. On ...


2

I don't know what makes you think F9 returning a tilde is "correct", but if you want a tilde, you should use the tilde key. Function keys are mostly undefined, based on the differences in the client-side hardware you are using, the client-side software you are using, the server-side software you are using, and the server-side hardware you are using.


2

The way you are doing this, with compressing a .tar file the answer is for sure no. Whatever you use for compressing the .tar file, it doesn't know about the contents of the file, it just sees a binary stream, and whether parts of that stream are uncompressable, or minimally compressible, there is no way this is known. Don't be confused by the options for ...


2

I would say that step 3 (Configuring) has failed. Didn't you got any error at step 3? (For the third step you need glibc also installed, make sure you have this). Furthermore, why don't you use the package management? Like apt-get install valgrind? Which distro are u using?


2

Tell cp to copy the directory's contents and not the directory itself: sudo cp -r /home/username/A/* /usr/lib/B/


1

To expand on what @Bratchley said in the comments, if you have your program's output printing to a file, then you can run then watch command in the terminal to get near-real-time view of the output by including the -n flag like so: watch -n 0.1 "cat yourprograms.log | sort | uniq -c | sort -rn" Note: The ' -n ' flag sets the refresh interval. The ...


1

With awk, it's awk -F '|' -v OFS='|' '{sub(/^.../, "& ", $4); print}' file But that cannot edit in-place, so you have to: t=$(mktemp) awk -F '|' -v OFS='|' '{sub(/^.../, "& ", $4); print}' file > "$t" && mv "$t" file With sed, sed -i 's/^[^|]*|[^|]*|[^|]*|.../& /' file If you want to validate the postal code, then sed -i ...


1

If you handle the True > true as mentioned elsewhere and get the jq tool, you can just do: jq '{tags}' <infile For example, after copying one of your examples to my clipboard: xsel -bo | sed 's/True/true/g' | jq '{tags}' OUTPUT: { "tags": { "type": [ "char" ], "dynamic": true } }


1

First of all, change True to true. As a whole, this works very well: #!/usr/bin/python import sys import json inputfile = sys.argv[1] with open(inputfile,'r') as myfile: obj = json.loads(myfile.read().replace('True','true')) if "map" in obj: del obj["map"] json.dump(obj,sys.stdout,indent=4,separators=(',',': ')) This writes to ...


1

The step ./configure normally reads Makefile.in and writes Makefile. Something went wrong in running it. Run it again and read the output looking for errors. If that fails, read config.log where you might find a clue about what went wrong.


1

Due to all help, I could find out how to fix this. The main issue is due to the UTF-8 encoding, the server didn't have it configured as said in comments. Quoting comments: [@Rmano]: In UTF-8 ñ is a two-bytes char [@jimmij]: backspace character for some reason deletes only one of them [@aecolley]: Try setting the environment variable LANG to C.UTF-8 ...


1

You might be looking for recordmydesktop. You can get a window id using wmctrl or xwininfo and then use that id: recordmydesktop --windowid <id_of_window> you can use --pause-shortcut to define a key combination for pause/continue.


1

The LZ4 algorithm could be an option. It checks if the beginning of a block is compressible and stores it uncompressed if the ratio is low. This sucessfully prevents compression of already compressed files without the need to specify their names. The overall compression ratio is lower compared to the algorithms you mention. But LZ4 is very fast, on the ...


1

Yea you would be disconnected. Like Celada say "Connecting to the console is the only safe way!". You can try this and if you can't reconnect with ssh, you can go to your console. But if you use the command: ifdown <interface-name> && ifup <interface-name> I think that's gonna be worked (But you gonna be disconnect).


1

In "recent" linux kernels, the kernel detects the hypervisor for you and prints a message that is easily available with dmesg. This will tell you simply: dmesg | grep "Hypervisor detected" For example: $ dmesg | grep "Hypervisor detected" Hypervisor detected: VMware As for what "recent" means, I am unclear which kernel version it was officially ...



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