Questions tagged [unix]

This tag is EXCLUSIVELY for PROGRAMMING questions that are directly related to Unix; general software issues should be directed to the Unix & Linux Stack Exchange site or to Super User. The Unix operating system is a general-purpose OS that was developed by Bell Labs in the late 1960s and today exists in various versions.

Tag usage

The tag can be used for Unix system programming related problems. The tag can also contain programming questions about using the Unix platform. For non-programming Unix usage questions, visit the Unix & Linux Stack Exchange site.

Background

Unix was developed as an in-house operating system for AT&T, but in the 1980s became both a prime academic operating system (with U.C. Berkeley's version, called BSD, being the reference platform for development of what would become the Internet) and a commercial success in the form of AT&T's System V, Microsoft/SCO's XENIX (PCs) and various workstation versions from Sun, Silicon Graphics, and others.

In the 1990s, Sun's Solaris and the free Unix clone Linux would rise in popularity. Linux is largely Unix-compatible but lacks the trademark. Currently, Unix is commonly found on server platforms; the primary desktop variant is Mac OS X, based on BSD.

Apart from its command-line interface, most "Unices" support the standardized X Window System for GUIs. (So does Mac OS X, but its primary GUI is Apple's proprietary Quartz.)

The various Unix implementation (and to a lesser extent, clones such as Linux) are unified in a standard called POSIX. C has been its primary programming language since the 1970s, but many other languages are available.

Read more

45195 questions
636
votes
21 answers

How can I copy the output of a command directly into my clipboard?

How can I pipe the output of a command into my clipboard and paste it back when using a terminal? For instance: cat file | clipboard
Legend
  • 104,480
  • 109
  • 255
  • 385
626
votes
7 answers

How do I get cURL to not show the progress bar?

I'm trying to use cURL in a script and get it to not show the progress bar. I've tried the -s, -silent, -S, and -quiet options, but none of them work. Here's a typical command I've tried: curl -s http://google.com > temp.html I only get the…
adammenges
  • 6,982
  • 3
  • 23
  • 27
620
votes
10 answers

How do I write stderr to a file while using "tee" with a pipe?

I know how to use tee to write the output (STDOUT) of aaa.sh to bbb.out, while still displaying it in the terminal: ./aaa.sh | tee bbb.out How would I now also write STDERR to a file named ccc.out, while still having it displayed?
jparanich
  • 6,916
  • 4
  • 22
  • 28
616
votes
12 answers

Find and replace in file and overwrite file doesn't work, it empties the file

I would like to run a find and replace on an HTML file through the command line. My command looks something like this: sed -e s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g index.html > index.html When I run this and look at the file afterward, it is…
BBales
  • 6,378
  • 3
  • 13
  • 18
592
votes
11 answers

How to pretty print XML from the command line?

Related: How can I pretty-print JSON in (unix) shell script? Is there a (unix) shell script to format XML in human-readable form? Basically, I want it to transform the following: lorem ... into…
svidgen
  • 13,099
  • 4
  • 31
  • 51
591
votes
3 answers

Why does ENOENT mean "No such file or directory"?

What does the ENT mean in ENOENT? Shouldn't the error: No such file or directory just be named by ENOFILE? Is there any story or reason?
mingchaoyan
  • 6,816
  • 2
  • 18
  • 28
588
votes
8 answers

How to do a logical OR operation for integer comparison in shell scripting?

I am trying to do a simple condition check, but it doesn't seem to work. If $# is equal to 0 or is greater than 1 then say hello. I have tried the following syntax with no success: if [ "$#" == 0 -o "$#" > 1 ] ; then echo "hello" fi if [ "$#" == 0…
Strawberry
  • 58,930
  • 53
  • 138
  • 190
584
votes
10 answers

How to split a large text file into smaller files with equal number of lines?

I've got a large (by number of lines) plain text file that I'd like to split into smaller files, also by number of lines. So if my file has around 2M lines, I'd like to split it up into 10 files that contain 200k lines, or 100 files that contain…
danben
  • 73,814
  • 18
  • 117
  • 141
581
votes
17 answers

Unix shell script find out which directory the script file resides?

Basically I need to run the script with paths related to the shell script file location, how can I change the current directory to the same directory as where the script file resides?
William Yeung
  • 9,370
  • 8
  • 34
  • 41
579
votes
25 answers

How can I extract a predetermined range of lines from a text file on Unix?

I have a ~23000 line SQL dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know both the start and end line numbers of the data that…
Adam J. Forster
  • 14,831
  • 9
  • 23
  • 20
579
votes
7 answers

How to read a file into a variable in shell?

I want to read a file and save it in variable, but I need to keep the variable and not just print out the file. How can I do this? I have written this script but it isn't quite what I needed: #!/bin/sh while read LINE do echo $LINE done <$1 …
kaka
  • 5,995
  • 4
  • 16
  • 22
554
votes
7 answers

What does the number in parentheses shown after Unix command names in manpages mean?

For example: man(1), find(3), updatedb(2)? What do the numbers in parentheses (Brit. "brackets") mean?
duckyflip
  • 14,979
  • 5
  • 31
  • 36
550
votes
10 answers

OS X: equivalent of Linux's wget

How can I do an HTTP GET from a Un*x shell script on a stock OS X system? (installing third-party software is not an option, for this has to run on a lot of different systems which I don't have control on). For example if I start the Mercurial…
SyntaxT3rr0r
  • 26,196
  • 20
  • 81
  • 119
547
votes
15 answers

How to colorize diff on the command line?

When I have a diff, how can I colorize it so that it looks good? I want it for the command line, so please no GUI solutions.
daniel kullmann
  • 12,359
  • 6
  • 48
  • 63
546
votes
15 answers

What does ^M character mean in Vim?

I keep getting ^M character in my vimrc and it breaks my configuration.
Max
  • 5,463
  • 3
  • 13
  • 6