Most Popular

1500 questions
284
votes
6 answers

redirecting to /dev/null

I'm reading an example bash shell script: #!/bin/bash # This script makes a backup of my home directory. cd /home # This creates the archive tar cf /var/tmp/home_franky.tar franky > /dev/null 2>&1 # First remove the old bzip2 file. Redirect…
JohnMerlino
  • 6,161
283
votes
34 answers

Markdown Viewer

I found a file formatted with Markdown. Could you suggest what viewer I could use to view this type of file? Hopefully one without a GUI, if it's possible. I am looking for a viewer that could parse markdown file format that does not need any…
Amree
  • 3,177
283
votes
24 answers

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something like: find /path/to/folder -name "filenamestart*"…
Toby
  • 3,993
282
votes
19 answers

How to add a newline to the end of a file?

Using version control systems I get annoyed at the noise when the diff says No newline at end of file. So I was wondering: How to add a newline at the end of a file to get rid of those messages?
k0pernikus
  • 15,463
282
votes
4 answers

How does a Segmentation Fault work under-the-hood?

I can't seem to find any information on this aside from "the CPU's MMU sends a signal" and "the kernel directs it to the offending program, terminating it". I assumed that it probably sends the signal to the shell and the shell handles it by…
Braden Best
  • 2,213
282
votes
16 answers

List available updates but do not install them

I want my cron-run reporting script to notify me in case there are updates for my packages. Is the a way to make apt-get give me the list of available updates but don't do anything more?
Morris
  • 2,829
  • 2
  • 15
  • 3
282
votes
5 answers

How to use find command to search for multiple extensions

I can get all jpg images by using: find . -name "*.jpg" But how can I add png files to the results as well?
wong2
  • 3,633
282
votes
8 answers

Extract only a specific file from a zipped archive to a given directory

I need to extract a single file from a ZIP file which I know the path to. Is there a command like the following: unzip -d . myarchive.zip path/to/zipped/file.txt Unfortunately, the above command extracts and recreates the entire path to the file at…
Naftuli Kay
  • 39,676
281
votes
10 answers

What is the real difference between "apt-get" and "aptitude"? (How about "wajig"?)

I know that both apt-get and aptitude are command line package management interfaces on Debian derived Linux, with different options, but I'm still somewhat confused. Under the hood, aren't they using the same APT system? Why does Debian maintain…
Kevin Cantu
  • 3,794
281
votes
3 answers

Find command: how to ignore case?

I am looking for file "WSFY321.c" in a huge directory hierarchy. Usually I would use GNU find: find . -name "WSFY321.c" But I do not know the case, it could be uppercase, lowercase, or a mix of both. What is the easiest way to find this file? Is…
279
votes
2 answers

Kernel inotify watch limit reached

I'm currently facing a problem on a linux box where as root I have commands returning error because inotify watch limit has been reached. # tail -f /var/log/messages [...] tail: cannot watch '/var/log/messages': No space left on device #…
Ultraspider
  • 3,073
278
votes
8 answers

Convince apt-get *not* to use IPv6 method

The ISP I work at is setting up an internal IPv6 network in preparation for eventually connecting to the IPv6 internet. As a result, several of the servers in this network now try to connect to security.debian.org via its IPv6 address by default…
277
votes
13 answers

Is there a one-liner that allows me to create a directory and move into it at the same time?

I find myself repeating a lot of: mkdir longtitleproject cd longtitleproject Is there a way of doing it in one line without repeating the directory name? I'm on bash here.
277
votes
5 answers

Why is using a shell loop to process text considered bad practice?

Is using a while loop to process text generally considered bad practice in POSIX shells? As Stéphane Chazelas pointed out, some of the reasons for not using shell loop are conceptual, reliability, legibility, performance and security. This answer…
cuonglm
  • 153,898
276
votes
13 answers

Execute a command once per line of piped input?

I want to run a java command once for every match of ls | grep pattern -. In this case, I think I could do find pattern -exec java MyProg '{}' \; but I'm curious about the general case - is there an easy way to say "run a command once for every line…
Xodarap
  • 3,683