Questions tagged [unix]

NOTICE: All Unix questions must be related to programming; those that aren't will be closed. Use this tag only if your question relates to programming using Unix APIs or Unix-specific behavior, not just because you happen to run your code on Unix. General software issues should be directed to Unix & Linux Stack Exchange or to Super User.

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

47509 questions
750
votes
12 answers

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

I know how to use tee to write the output (standard output) of aaa.sh to bbb.out, while still displaying it in the terminal: ./aaa.sh | tee bbb.out How would I now also write standard error to a file named ccc.out, while still having it displayed?
jparanich
  • 8,372
  • 4
  • 26
  • 34
748
votes
4 answers

How to download a file from server using SSH?

I need to download a file from server to my desktop. (UBUNTU 10.04) I don't have a web access to the server, just ssh. If it helps, my OS is Mac OS X and iTerm 2 as a terminal.
NiLL
  • 13,645
  • 14
  • 46
  • 59
746
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
  • 7,848
  • 5
  • 26
  • 33
722
votes
9 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
  • 7,425
  • 4
  • 19
  • 23
701
votes
4 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
  • 8,096
  • 3
  • 23
  • 31
694
votes
12 answers

How can I split a large text file into smaller files with an 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
  • 80,905
  • 18
  • 123
  • 145
673
votes
19 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
  • 10,368
  • 9
  • 36
  • 42
671
votes
12 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,744
  • 4
  • 33
  • 58
652
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
  • 16,189
  • 5
  • 33
  • 36
638
votes
15 answers

What does the ^M character mean in Vim?

I keep getting the ^M character in my .vimrc and it breaks my configuration.
Max
  • 6,383
  • 3
  • 15
  • 6
635
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,588
  • 3
  • 16
  • 19
631
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
  • 27,745
  • 21
  • 87
  • 120
614
votes
6 answers

What is the difference between "#!/usr/bin/env bash" and "#!/usr/bin/bash"?

In the header of a Bash script, what's the difference between those two statements: #!/usr/bin/env bash #!/usr/bin/bash When I consulted the env man page, I get this definition: env - run a program in a modified environment What does it mean?
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96
608
votes
17 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
  • 13,653
  • 8
  • 51
  • 67
599
votes
7 answers

How to run a shell script on a Unix console or Mac terminal?

I know it, forget it and relearn it again. Time to write it down.
P-A
  • 10,882
  • 8
  • 26
  • 19