The command-line is the interactive interface to your shell.

learn more… | top users | synonyms (1)

11
votes
4answers
452 views

rolling diffs for storage of highly similar files?

At work we do a nightly dump of our mysql databases. From day to day, I would guestimate that close to 90-95% of the data is duplicate, increasing as time goes on. ( Heck at this point some are ...
11
votes
5answers
2k views

Using text from previous commands' output

I know this is not how terminals work, but I find myself often wishing there was an easy way of using text (copying it, modifying it, etc) that is already on my terminal window history from some ...
10
votes
2answers
615 views

Highlight the three last updated files in ls output

Is there any way to overload or wrap the ls command so that it will highlight / underline / otherwise make obvious the last three modified files? I know that I can simply ls -rtl to order by reverse ...
8
votes
1answer
11k views

command to zip multiple directories into individual zip files

I have a single directory that contains dozens of directories inside of it. I'm new to command line and I'm struggling to come up with a command that will zip each sub-directory into a unique ...
8
votes
3answers
654 views

how to queue a command to run after another command finishes?

Sometimes I start a program that takes a very long time to finish (emerge), then realize that I should go to bed instead of waiting for it. If I know this in the first place I would run program; halt ...
22
votes
5answers
26k views

How do I convert an epoch timestamp to a human readable format on the cli?

How do I convert an epoch timestamp to a human readable format on the cli? I think there's a way to do it with date but the syntax eludes me (other ways welcome).
17
votes
6answers
2k views

Why do I have to cd out of a deleted directory?

On my server I have a directory structure looking something like this: /myproject/code I normally have an ssh connection to the server and 'stand' in that directory: root@machine:/myproject/code# ...
16
votes
1answer
2k views

copy (to X clipboard) shortcut in .tmux.conf

In order to copy text to X clipboard in tmux, what I currently do is: go selection mode with prefix[ start selection with space (using mode-keys vi btw) select the text and press enter copy tmux ...
16
votes
10answers
13k views

What's a good example of piping commands together?

If you were helping someone to learn the concept of pipes on the command line what example would you use? The example that actually came up was as follows: cat whatever.txt | less I feel like ...
15
votes
3answers
588 views

Why don't shell builtins have proper man pages?

All shell builtins share the same manual page: BUILTIN(1) BSD General Commands Manual BUILTIN(1) NAME builtin, ! etc. Then there is a little text describing ...
15
votes
3answers
4k views

Command for forcing a pointer ungrab (captured mouse release)

Sometimes Firefox doesn't release the mouse after dragging, so I need to kill the application to force it to release its pointer grab. Is there any command to force an application to ungrab the ...
12
votes
2answers
2k views

Where do my ANSI escape codes go when I pipe to another process? Can I keep them?

I sometime want to pipe the color-coded output fror a process, eg. grep... but when I pipe it to another process, eg. sed, the color codes are lost... Is the some way to keep thes codes intact ? ...
10
votes
3answers
7k views

copy recursively except hidden directory

How do I copy recursively like cp -rf *, but excluding hidden directories (directories starting with .) and their contents?
8
votes
2answers
28k views

How to display open file descriptors but not using lsof command

Hi I have read Here that lsof is not an accurate way of getting the number of File Descriptors that are currently open. He recommended to use this command instead cat /proc/sys/fs/file-nr While ...
18
votes
5answers
829 views

Difference between “. myscript” and “./myscript” [duplicate]

I am confused by "one only dot - space - shell script name" (like . myshellscript) and "path to shell script" (like ./myshellscript) commands. What for they are? I noticed the command . myshellscript ...
13
votes
3answers
1k views

How can I keep control+d from disconnecting my session?

I regularly ssh to a centos 5 box. Somehow they keys are mapped so that control+d will log me out of my current shell. If I am sudo'ed to another use it puts me back to the previous user. If I am not ...
11
votes
3answers
3k views

How can I pipe output to another process, but retain the error state of the first process? [duplicate]

Possible Duplicate: Get exit code of process that's piped to another I am using the following command line (in a makefile) to pipe the verbose error messages from my compiler through a ...
11
votes
7answers
11k views

grep and tail -f?

Is it possible to do a tail -f (or similar) on a file, and grep it at the same time? I wouldn't mind other commands just looking for that kind of behavior.
10
votes
4answers
21k views

How to check password with Linux?

I want to check, from the linux command line, if a given cleartext password is the same of a crypted password on a /etc/shadow (I need this to authenticate web users. I'm running an embedded linux.) ...
9
votes
7answers
6k views

How do you bulk move files up one directory safely?

How can I move files up a directory where there might be hundreds or thousands of files in the directory, and you might not be sure about whether there are dupes in ... What method would you use? How ...
8
votes
3answers
761 views

Bash: Capture / Use last (or Nth) line in stdout

Query I use Bash. When I'm looking for files, often I'll do the following: find -name stackexchange.hs And often the results will look like: /youre/the/man/now/dog/stackexchange.hs ...
7
votes
2answers
3k views

How do I merge two *.srt files

Please see this question. I have just merged two avi files cd1.avi and cd1.avi into movie.avi using: avimerge -o movie.avi -i cd{1,2}.avi Problem is that I had to subtitle files linked to the ...
7
votes
4answers
2k views

How to best encrypt and decrypt a directory via the command line or script?

I have a directory of text files under bazaar version control and keep a copy (a branch, actually) on each of my machines. I want to encrypt and unencrypt the directory via the command line. Ideally, ...
6
votes
3answers
2k views

Easy way to paste command line output to paste bin services?

Are there any command line tools on Linux that allow you to post output from commands or text files directly to a sharing service such as pastebin.com?
6
votes
2answers
3k views

using the mail command

How do I use the mail command to check email (and send email) from gmail. Does it support labels? I couldn't have figure out where to put the username and password. I tried to search for instruction ...
6
votes
2answers
6k views

How do I insert a space every four characters in a long line?

I've got a long line that I want to insert a space every 4 characters, on a single lone line of solid text to make it easier to read, what's the simplest way to do this? also I should be able to input ...
3
votes
2answers
11k views

No network connection in CentOS 6.3 Minimal under VMWare Player

I'm trying to replicate in VMWare Player the exact same conditions I have under my Dedicated Server for testing purposes. Now, the thing is that that when I try to install something, or ping ...
12
votes
1answer
7k views

ls taking long time in small directory

Running Ubuntu, I open a terminal and do sudo bash cd / ls | head -n 1000 And predictably about 20 directories are returned. However, if I do an ls, and don't pipe it into anything, the ls just ...
11
votes
3answers
17k views

How do I put a hat on 'e' (ê)?

Since I've migrated to linux a few years ago, one issue still remains. The ê character features a lot in my "moeder taal" (home language). In Windows making the character was easy, I simply had to ...
10
votes
4answers
23k views

How to boot Linux to command-line mode instead of GUI?

I am using 32-bit Red Hat Linux in my VM. I want to boot it to command-line mode, not to GUI mode. I know that from there I can switch to GUI mode using startx command. How do I switch back to ...
10
votes
4answers
4k views

Remove all `at` jobs

I know that to remove a scheduled at job I have to use atrm "numjob1 numjob2", but is there an easy way to do that for all the jobs?
10
votes
2answers
1k views

Where has the trailing newline char gone from my command substitution?

The following code best describes the situation.  Why is the last line not outputting the trailing newline char?  Each line's output is shown in the comment.  I'm using GNU bash, version 4.1.5 ...
8
votes
3answers
8k views

Safe way to pass password for >1 programs in bash

I'm writing a bash script, and need to ask user for his password and pass it to openssl. Whilst openssl can read the password itself, I need for two runs of the program and don't want to ask the user ...
8
votes
1answer
380 views

Is there a way to make perl -i not clobber symlinks?

A friend of mine points out that if you do: perl -pi.bak -e 's/foo/bar/' somefile when "somefile" is actually a symlink, perl does just what the docs say it will do: It does this by renaming ...
7
votes
4answers
415 views

How to randomize the output from seq?

I know I can use seq to generate a random list of numbers 1, 2, 3, 4... I want to get those numbers into a random order like 3, 1, 4, 2... I know I can use shuf to shuffle the lines of a file. So I ...
7
votes
1answer
17k views

Using --exclude with the du command

This is probably something basic but I'm not able to make it work. I'm trying to use DU to get a total size of files minus certain directories. I need to exclude one specific directory called uploads ...
6
votes
5answers
1k views

resolve all ip addresses in command output using standard command line tools

I have several log files that contain a bunch of ip addresses. I would love to be able to pipe the data through a program that would match and resolve ip addresses. I.E. cat /var/log/somelogfile | ...
6
votes
4answers
535 views

pager program like less, able to repeat top N lines

Is there any way to make less program repeat first line (or first 2 lines) on every displayed page? Is there any other pager program which can do this? This would be a killer-app for database table ...
5
votes
4answers
10k views

Move all files with a certain extension from multiple subdirectories into one directory

Suppose I have a bunch of zip files in several directories: Fol1/Fol2 Fol3 Fol4/Fol5 And I want to move them all to a common base folder. How would I do this?
3
votes
2answers
419 views

I need help with a cronjob to watch for runaway processes and kill them

I have an interesting situation, I have a runaway ruby process - I know exactly how I trigger it. Point is, it got me thinking about runaway processes (CPU usage or memory usage). How would one ...
2
votes
1answer
421 views

cat file to multicast

I have a text file (test.txt) which represents captured network data. The actual protocol is text-based, with NULL line endings, so this isn't a problem. I need to run this test captured data ...
2
votes
1answer
264 views

Simpler processing of shell script options

I'm looking for way to process shell script arguments that is cleaner and more "self documenting" than getopt/getopts. It would need to provide... Full support of long options with or without a ...
15
votes
3answers
2k views

Why isn't there any shell command to create files?

Attention please: I am not asking how to make a file from the command line! I have been using touch for making files for years without paying attention that its main purpose is something else. If ...
12
votes
6answers
25k views

What is the fastest way to view images from the terminal?

The terminal is very fast and convenient way to quickly access directories and files (faster than find and click on the directory). One thing that it cannot show in text-mode is "pictures". What ...
12
votes
2answers
2k views

IP to Country console command

Is there a console command that takes an IP address as an input and shows its geographical information like city, country, ISP, etc.?
11
votes
5answers
17k views

Linux ls to show only filename date and size

How can I use ls in linux to get a listing of filenames date and size only. I don't need to see the other info such as owner or permission. Is this possible?
11
votes
5answers
4k views

How to soft kill gui applications via terminal?

Is there a way to close a GUI application in friendly "please quit yourself now" way, without graphical access to the applications window? For example, if Gnome/X display crashes to black, I'd like ...
10
votes
3answers
4k views

How to launch a set of program inside tmux or gnome-terminal within a script?

I wanted to launch a few commands simultaneously in tmux or gnome-terminal or xfterminal , every different tab with a single command running , and close that tab when that command finishes. Any ...
9
votes
11answers
9k views

How can I “cat” a file and remove commented lines?

I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ; For example, if the file contained this: ; - Show all errors, except for notices ; ...
8
votes
3answers
2k views

How can I print good looking code

Similar to using markdown on Stack Overflow to create monospace output, how can I do that for my programs. I tried lp filename.txt and was pleasantly please to find that it was able to use the local ...