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
23
votes
14 answers

Date arithmetic in Unix shell scripts

I need to do date arithmetic in Unix shell scripts that I use to control the execution of third party programs. I'm using a function to increment a day and another to decrement: IncrementaDia(){ echo $1 | awk ' BEGIN { diasDelMes[1] = 31 …
ggasp
  • 1,490
  • 3
  • 15
  • 24
23
votes
2 answers

On Unix, find if user who executed the program is root?

I'm writing a rake script and would like to detect (using Ruby rather than bash if possible) if the user who executed the rake script has root privileges. If it is not root then I would like to terminate the script.
ChrisInCambo
  • 8,455
  • 15
  • 50
  • 63
23
votes
4 answers

Remove all lines except matching pattern line best practice (sed)

I want to remove all lines except the line(s) containing matching pattern. This is how I did it: sed -n 's/matchingpattern/matchingpattern/p' file.txt But I'm just curious because I rename matching pattern to the matching pattern itself. Looks like…
kopelkan
  • 1,135
  • 2
  • 9
  • 8
23
votes
7 answers

Unix cp argument list too long

I am using AIX. When I try to copy all the file in a folder to another folder with the following command: cp ./00012524/*.PDF ./dummy01 The shell complains: ksh: /usr/bin/cp: 0403-027 The parameter list is too long. How to deal with it? My folder…
lamwaiman1988
  • 3,729
  • 15
  • 55
  • 87
23
votes
4 answers

What actually the meaning of "-n" in sed?

According to http://linux.about.com/od/commands/l/blcmdl1_sed.htm suppress automatic printing of pattern space I've tested with or without -n, sed will produce same result I dont understand what space does it means.
Jon Maikel
  • 233
  • 1
  • 2
  • 4
23
votes
4 answers

How do I make Windows file-locking more like UNIX file-locking?

UNIX file-locking is dead-easy: The operating system assumes that you know what you are doing and lets you do what you want: For example, if you try to delete a file which another process has opened the operating system will usually let you do it.…
Salim Fadhley
  • 22,020
  • 23
  • 75
  • 102
23
votes
6 answers

Shell Variable capacity

Suppose i have a shell script in which there is a statement like : a=$(find / -type f) This says there is a certain list of files with their file paths which will be stored in the variable 'a'. What is the maximum limit or number of lines that it…
Vijay
  • 65,327
  • 90
  • 227
  • 319
23
votes
2 answers

Thread name longer than 15 chars?

By using functions like prctl, or pthread_set_name_np it's possible to change the name of a thread. The limit both functions imposes, at least in Linux 2.6.38, is that the name cannot be longer than 15 characters (NULL termination being the 16th…
dsvensson
  • 1,401
  • 12
  • 20
23
votes
1 answer

How do I determine if a directory is a mounted NFS mount point in shellscript

I want to write a sh/bash script that can determine whether a particular directory is a mount point for an NFS filesystem. eg something like $ mkdir localdir $ mkdir remotedir $ mount host:/share ./remotedir $ classify_dirs.sh --> localdir is…
AndrewR
  • 10,759
  • 10
  • 45
  • 56
23
votes
5 answers

What is the difference between find with grep?

What is the difference between these command: find . –type f –name '*txt*' and find . –type f | grep 'txt' I tried to run this and there is a difference but I want to know why?
tn2000
  • 642
  • 1
  • 8
  • 13
23
votes
7 answers

launch a CAT command unix into Dockerfile

I would like to launch this vagrant command cat(run perfectly!) to provisionning my container with a Dockerfile : # Configure Virtualenvwrapper. RUN cat <> /home/docker/.bashrc # Virtualenvwrapper configuration. export…
miltone
  • 4,416
  • 11
  • 42
  • 76
23
votes
3 answers

Fair comparison of fork() Vs Thread

I was having a discussion about the relative cost of fork() Vs thread() for parallelization of a task. We understand the basic differences between processes Vs Thread Thread: Easy to communicate between threads Fast context…
Martin York
  • 257,169
  • 86
  • 333
  • 562
23
votes
5 answers

mutt: Error sending message, child exited 127 (Exec error.)

I have to send a mail with an attachment from a shell script. I am trying to do it using mutt as shown here: How do I send a file as an email attachment using Linux command line? Command: echo "This is the message body" | mutt -a…
Aditya
  • 1,136
  • 2
  • 12
  • 19
23
votes
3 answers

Starting a new tmux session and detaching it, all inside a shell script

I am trying to create a new tmux session and execute the command 'vagrant up'. 'Vagrant up' takes more than 3 hours so I want to detach the session so that I can come back later and check the status of that command by attaching back to the same…
Swarup Donepudi
  • 984
  • 1
  • 11
  • 23
23
votes
7 answers

Joining two consecutive lines using awk or sed

How would I join two lines using awk or sed? I have data that looks like this: abcd joinabcd efgh joinefgh ijkl joinijkl I need an output like the one below: joinabcdabcd joinefghefgh joinijklijkl
Vijay
  • 65,327
  • 90
  • 227
  • 319