Most Popular
1500 questions
319
votes
23 answers
How to have tail -f show colored output
I'd like to be able to tail the output of a server log file that has messages like:
INFO
SEVERE
etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I setup for a tail command that would help me do this?
Amir Afghani
- 7,083
- 11
- 26
- 23
319
votes
5 answers
How can I get the current working directory?
I want to have a script that takes the current working directory to a variable. The section that needs the directory is like this dir = pwd. It just prints pwd how do I get the current working directory into a variable?
user104976
318
votes
3 answers
How can I make "Press any key to continue"
I'm making a script to install my theme, after it finished installing it will appear the changelog and there will be "Press any key to continue" so that after users read the changelog then press any key to continue
superquanganh
- 3,721
- 5
- 14
- 14
316
votes
12 answers
How can I test if a variable is empty or contains only spaces?
The following bash syntax verifies if param isn't empty:
[[ ! -z $param ]]
For example:
param=""
[[ ! -z $param ]] && echo "I am not zero"
No output and its fine.
But when param is empty except for one (or more) space characters, then the…
maihabunash
- 6,973
- 19
- 64
- 80
315
votes
8 answers
How to reload udev rules without reboot?
How should one reload udev rules, so that newly created one can function?
I'm running Arch Linux, and I don't have a udevstart command here.
Also checked /etc/rc.d, no udev service there.
daisy
- 53,527
- 78
- 236
- 383
315
votes
7 answers
How create a temporary file in shell script?
While running a script, I want to create a temporary file in /tmp directory.
After execution of that script, that will be cleaned by that script.
How to do that in shell script?
Bhuvanesh
- 3,285
- 3
- 12
- 7
315
votes
3 answers
Can I remove files in /var/log/journal and /var/cache/abrt-di/usr?
I use Fedora and these directories contains a large amount of files, I wonder whether I can delete them? The system is running low on space.
hgajshb
- 3,715
- 4
- 18
- 18
314
votes
7 answers
What's the point in adding a new line to the end of a file?
Some compilers (especially C or C++ ones) give you warnings about:
No new line at end of file
I thought this would be a C-programmers-only problem, but github displays a message in the commit view:
\ No newline at end of file
for a PHP file.
I…
Philipp Stephan
- 3,250
- 2
- 15
- 8
313
votes
10 answers
Can rsync resume after being interrupted?
I used rsync to copy a large number of files, but my OS (Ubuntu) restarted unexpectedly:
sudo rsync -azvv /home/path/folder1/ /home/path/folder2
After reboot, I ran rsync again, but from the output on the terminal, I found that rsync still copied…
Tim
- 98,580
- 191
- 570
- 977
313
votes
10 answers
What is the "eval" command in bash?
What can you do with the eval command? Why is it useful? Is it some kind of a built-in function in bash? There is no man page for it..
LanceBaynes
- 39,295
- 97
- 250
- 349
313
votes
3 answers
How to import secret gpg key (copied from one machine to another)?
I'm trying to copy my gpg key from one machine to another.
I do:
gpg --export ${ID} > public.key
gpg --export-secret-key ${ID} > private.key
Move files to new machine, and then:
gpg --import public.key
gpg: nyckel [ID]: public key [Name, e-mail]…
user50849
- 5,082
- 5
- 25
- 30
311
votes
11 answers
how can I make cron run a job right now, for testing/debugging? without changing the schedule!
I have a cron job that is scheduled to run everyday, other than changing the schedule, is there any other way to do a test run of the command right now to see if it works as intended?
EDIT: (from the comments) I know the command works fine when…
Ali
- 6,693
- 6
- 32
- 37
311
votes
1 answer
How to change where a symlink points
Can you tell me what this is in the area marked red?
If I want to change /media/files/tb-prod/files to some other path, how would I do that?
Jalil Khan
- 3,221
- 2
- 12
- 11
311
votes
25 answers
Colorizing your terminal and shell environment?
I spend most of my time working in Unix environments and using terminal emulators. I try to use color on the command line, because color makes the output more useful and intuitive.
What options exist to add color to my terminal environment? What…
Stefan Lasiewski
- 19,264
- 24
- 70
- 85
309
votes
12 answers
Better colors so comments aren't dark blue in Vim?
Mostly I edit Ruby files, although shell script file comments are also #
Currently my comments show as dark blue on black which is really hard to read.
See screenshot.
How can I change their color?
I'm willing to consider different schemas for all…
Michael Durrant
- 41,213
- 69
- 165
- 232