Tag Info

New answers tagged

0

#!/usr/bin/env bash May or may not increase the portability, as if bash is actually installed on a *BSD system, it usually exists at /usr/local/bin/bash. However, env may not be portable, though that would only be for really old or weird unix systems. ps is an especially not-portable command, especially if you intend to use BSD/GNUisms on a SysV system ...


0

How are received bytes stored? From the user space's point of view, they are not stored at all. How to read them? If you mean only to read them, simply cat /dev/ttyS... will do. Some more information as to how to deal with serial interfaces can be seen in multitude of answers and comments in this page and in the internet in general withing seconds of ...


0

It should be available on all Linuxes. Linux 4.1 Documentation/devices.txt says: Compulsory links These links should exist on all systems: /dev/fd /proc/self/fd symbolic File descriptors /dev/stdin fd/0 symbolic stdin file descriptor /dev/stdout fd/1 symbolic stdout file descriptor /dev/stderr fd/2 symbolic ...


4

Linux, like most Unix-like systems (Apple OS/X being one of the rare exceptions), ignores permissions on symlinks when it comes to resolving their targets for instance. However ownership of symlinks, like other files, is relevant when it comes to the permission to rename or unlink their entries in directories that have the t bit set, such as /tmp. To be ...


0

There is no lchmod() in posix but fchmodat() that would allow to set the permissions of a symlink. This still does not require the permissions of symlinks to be evaluated.


2

POSIXly: sed 's/[^[:alnum:]_-]//g' will remove everything is not alpha numeric characters in your current locale, _ and -. $ echo 'foo-bar |' | sed -e 's/[^[:alnum:]_-]//g' foo-bar But if you want to print everything until first space: sed -e 's/^\([^ ]*\) .*/\1/' or awk: awk '{print $1}'


1

Various layers within Linux, also showing separation between the userland and kernel space for full image Source


0

Hmm, looks like bash is still fails the prefix notation, thus $ < /etc/passwd while read line; do echo $line; done bash: syntax error near unexpected token `do' while zsh does allow this redirection prior to the while loop.


1

sed operates on pattern space. I think POSIX sed page is pretty clear: APPLICATION USAGE Regular expressions match entire strings, not just individual lines, but a <newline> is matched1 by '\n' in a sed RE; a <newline> is not allowed by the general definition of regular expression in POSIX.1-2008. Also note that '\n' cannot be ...


2

^ and $ in BRE always match at the start and end of line, as describe here. Any sed which use BRE will do the same way. In case of using N command, sed saw multi lines as one long line in pattern space, with each real line separated by embedded newline \n (literal \ and n). For confirmation: printf '1\n2\n' | sed '1N;/2$/d' output nothing. And: printf ...


3

That behavior was defined by POSIX here: If more than one redirection operator is specified with a command, the order of evaluation is from beginning to end. and here: A "simple command" is a sequence of optional variable assignments and redirections, in any sequence, optionally followed by words and redirections, terminated by a control ...


8

Here is a portable way : java -version 2>&1 | PATH=`getconf PATH` awk -F '"' '/version/ {print $2}' Unlike the usual suggestions that try to guess the correct location depending on the Unix implementation, it uses the getconf PATH command that returns the path to POSIX compliant commands.


3

Most important things POSIX 7 defines C API Extends ANSI C with things like: networking, process and thread management, file IO, regular expressions, ... E.g.: write, open, read, ... Those APIs also determine underlying system concepts on which they depend. Many Linux system calls exist to implement a specific POSIX C API function and make Linux ...


4

It really seems to me that the Unix community is killing themselves in the Desktop world. I think there is a misconception that any form of Unix exists in order to compete in the home PC market. There are some linux distros which have this focus; the first one was really Ubuntu, but it is worth considering that part of Ubuntu's original vision was to ...


2

Unix has specifications/a standard they hope you'll follow, POSIX, ways things should be implemented, though up to the developer, it's a standard we should follow if we want our code to work on many architectures/platforms/systems whatever, up to the developer at the end of the day to follow what (hopefully) majority of developers are following. Windows has ...


10

To be called UNIX you need to go through a certification process that requires (among other things) that you implement the POSIX standard. So your question is completely invalid. There is UNIX API, it's called POSIX. EDIT: Here is the list of requirements: http://www.unix.org/version4/overview.html


10

In Bourne-like shells (if we forget about bugs1 in some old implementations of some shells) var=$otherVar is fine. You're assigning to a scalar variable, so there can't be glob+splitting here, so you don't need to write it var="$otherVar" (though the quotes don't harm here). An exception is for: var=$* and: var=$@ You should only use var="$*". The ...



Top 50 recent answers are included