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
21
votes
6 answers

How to replace newlines with tab characters?

I have pattern like below hi hello hallo greetings salutations no more hello for you I am trying to replace all newlines with tab using the following command sed -e "s_/\n_/\t_g" but it's not working. Could anybody please help? I'm looking for a…
Vijay
  • 65,327
  • 90
  • 227
  • 319
21
votes
5 answers

Bash arrays and negative subscripts, yes or no?

The GNU bash manual tells me An indexed array is created automatically if any variable is assigned to using the syntax name[subscript]=value The subscript is treated as an arithmetic expression that must evaluate to a number. If subscript…
bob.sacamento
  • 6,283
  • 10
  • 56
  • 115
21
votes
3 answers

Use bash to read a file and then execute a command from the words extracted

FILE: hello world I would like to use a scripting language (BASH) to execute a command that reads each WORD in the FILE above and then plugs it into a command. It then loops to the next word in the list (each word on new line). It stops when it…
user191960
  • 1,941
  • 5
  • 20
  • 24
21
votes
2 answers

What's a file descriptor's "exception"?

When one calls select() asking which file descriptors have "exceptions" waiting, what does that mean? How does one trigger one of these "exceptions"? If anyone can point me to a nice explanation, that'd be awesome. I've been googling and can't find…
Verdagon
  • 2,456
  • 3
  • 22
  • 36
21
votes
2 answers

Get the latest file in directory

I need to get the latest directory name in a folder which start with nlb. #!/bin/sh cd /home/ashot/checkout dirname=`ls -t nlb* | head -1` echo $dirname When the folder contains many folders with name starting nlb, this script works fine,…
Ashot
  • 10,807
  • 14
  • 66
  • 117
21
votes
4 answers

How does execvp run a command?

I know execvp can be used to execute simple commands as follows: char* arg[] = {"ls", "-l", NULL}; execvp(arg[0],arg); I want to know what goes on in here when I run execvp. In man page it says execvp replaces the image of the process image with…
as3rdaccount
  • 3,711
  • 12
  • 42
  • 62
21
votes
1 answer

Is nesting of Here Document possible in a unix bash script?

Is it possible to write a heredoc within another heredoc ? ssh -T -q yxz@server1 <<-"END_TEXT" . . ssh -T -q abc@server2 <<-"SUB_TEXT" . . SUB_TEXT . . END_TEXT
kaustav datta
  • 687
  • 2
  • 11
  • 31
21
votes
4 answers

Pass a Multiline,Quoted string as a single command line argument in unix?

I just need to pass any HTML content as a command line argument which includes characters like ', " , ` and what not? How can I pass this as a single argument in unix?
Cookies
  • 675
  • 1
  • 8
  • 17
21
votes
5 answers

Why is the st_size field in struct stat signed?

st_size is defined as being an off_t. off_t is defined as being a signed integer type. Why is st_size defined as a signed type? Can it be negative? What does it mean if it is negative?
user1290696
  • 489
  • 1
  • 4
  • 10
21
votes
5 answers

Grep across multiple files in Hadoop Filesystem

I am working with Hadoop and I need to find which of ~100 files in my Hadoop filesystem contain a certain string. I can see the files I wish to search like this: bash-3.00$ hadoop fs -ls /apps/mdhi-technology/b_dps/real-time ..which returns several…
arsenal
  • 23,366
  • 85
  • 225
  • 331
21
votes
1 answer

Specify Destination Directory for 'zip' Command Output (The Zip file that is Created)

The zip command generally places the output zip file in the current directory. But, I'm wondering if there is an option that I'm overlooking in the man page that lets me specify the destination directory for the output archive file. This created…
nemo
  • 1,504
  • 3
  • 21
  • 41
21
votes
2 answers

OpenSSL create SHA hash from shell stdin

How to generate the SHA-512 hash with OpenSSL from command line without using a file? I've tried this echo "password" | openssl dgst -sha512 but the hash looks wrong (compared with http://hash.online-convert.com/sha512-generator).
user1256821
  • 1,158
  • 3
  • 15
  • 35
21
votes
6 answers

Unix command to find string set intersections or outliers?

Is there a UNIX command on par with sort | uniq to find string set intersections or "outliers". An example application: I have a list of html templates, some of them have {% load i18n %} string inside, others don't. I want to know which files…
Evgeny
  • 10,698
  • 9
  • 60
  • 70
20
votes
9 answers

'tee' and exit status

Is there an alternative to tee which captures standard output and standard error of the command being executed and exits with the same exit status as the processed command? Something like the following: eet -a some.log -- mycommand --foo…
pachanga
  • 3,003
  • 4
  • 30
  • 45
20
votes
3 answers

How to add a string at the beginning of each line in a file

I want to add a specific string at the beginning of each line in a file. So, if I have the below two lines in someFile.txt and want to add a date string 03/06/2012 with pipe- Hello|there|john Hello|there|joel I would…
Sajal Dutta
  • 18,272
  • 11
  • 52
  • 74