Questions tagged [bsd]

BSD is a family of Unix-like operating systems, including FreeBSD, NetBSD and OpenBSD.

510 questions
330
votes
15 answers

sed in-place flag that works both on Mac (BSD) and Linux

Is there an invocation of sed todo in-place editing without backups that works both on Linux and Mac? While the BSD sed shipped with OS X seems to need sed -i '' …, the GNU sed Linux distributions usually come with interprets the quotes as empty…
dnadlinger
  • 5,883
  • 4
  • 21
  • 24
179
votes
4 answers

sed command with -i option (in-place editing) works fine on Ubuntu but not Mac

I know nothing about Sed but need this command (which works fine on Ubuntu) to work on a Mac OSX: sed -i "/ $domain .*#drupalpro/d" /etc/hosts I'm getting: sed: 1: "/etc/hosts": extra characters at the end of h command
Michelle Williamson
  • 2,516
  • 4
  • 18
  • 19
157
votes
6 answers

How do I determine the target architecture of static library (.a) on Mac OS X?

I'm interested in verifying if a given iPhone static library has been built for ARM or Intel. It's more curiosity than anything. Is there some kind of Mac OS X or BSD specific tool to do this? This post gives an example in Linux.
Justicle
  • 14,761
  • 17
  • 70
  • 94
102
votes
16 answers

How do I timestamp every ping result?

Ping returns this by default: 64 bytes from 203.173.50.132: icmp_seq=0 ttl=244 time=57.746 ms Is there some way I can get it to add the timestamp? For example, Mon 21 May 2012 15:15:37 EST | 64 bytes from 203.173.50.132: icmp_seq=0 ttl=244…
John Mee
  • 50,179
  • 34
  • 152
  • 186
101
votes
4 answers

What is the status of POSIX asynchronous I/O (AIO)?

There are pages scattered around the web that describe POSIX AIO facilities in varying amounts of detail. None of them are terribly recent. It's not clear what, exactly, they're describing. For example, the "official" (?) web site for Linux…
Glyph
  • 31,152
  • 11
  • 87
  • 129
40
votes
3 answers

Multiple replacements with one sed command

I'm wondering how I can do a multiple find/replace using a single sed statment in Mac OSX. I'm able to do this in Ubuntu but because of the BSD nature of OSX, the command must be slightly altered. So, given a file with the string: "Red Blue Red…
user1026361
  • 3,627
  • 3
  • 22
  • 20
36
votes
2 answers

What does -D_DEFAULT_SOURCE do?

Previously I was receiving warnings from gcc -std=c99 that usleep() was implicitly declared. Then I stumbled across this stackoverflow post, which led me to use -D_BSD_SOURCE. However, now gcc tells me that -D_BSD_SOURCE has been deprecated and I…
ryanmjacobs
  • 575
  • 1
  • 5
  • 9
35
votes
3 answers

BSD sed: extra characters at the end of d command

I use sed command on mac OS, following is the text. $ cat pets.txt This is my cat my cat's name is betty This is your dog your dog's name is frank This is your fish your fish's name is george This is my goat my goat's name is adam when I…
lutaoact
  • 4,149
  • 6
  • 29
  • 41
28
votes
4 answers

How can I detect BSD vs. GNU version of date in shell script

I am writing a shell script that needs to do some date string manipulation. The script should work across as many *nix variants as possible, so I need to handle situations where the machine might have the BSD or the GNU version of date. What would…
bryan kennedy
  • 6,969
  • 5
  • 43
  • 64
28
votes
12 answers

Alternative way to obtain argc and argv of a process

I'm looking for alternative ways to obtain the command line parameters argc and argv provided to a process without having direct access to the variables passed into main(). I want to make a class that is independent of main() so that argc and argv…
user1095108
  • 14,119
  • 9
  • 58
  • 116
27
votes
2 answers

How to use list from sys/queue.h?

Currently, I have implemented a singly linked list, like so: struct PeerNode { struct Peer* cargo; struct PeerNode* next; }; ...and I have a struct that contains a couple of these linked lists, like so: struct Torrent { ... …
rps
  • 1,263
  • 3
  • 13
  • 18
26
votes
5 answers

Get real path of application from pid?

How can I get the process details like name of application & real path of application from process id? I am using Mac OS X.
RLT
  • 4,219
  • 4
  • 37
  • 91
23
votes
2 answers

sed not giving me correct substitute operation for newline with Mac - differences between GNU sed and BSD / OSX sed

I'm using this reference : sed help: matching and replacing a literal "\n" (not the newline) and I have a file "test1.txt" that contains a string hello\ngoodbye I use this command to search and replace "\n" with actual new line characters: sed -i ''…
Brandon Ling
  • 3,841
  • 6
  • 34
  • 49
22
votes
8 answers

Detecting a chroot jail from within

How can one detect being in a chroot jail without root privileges? Assume a standard BSD or Linux system. The best I came up with was to look at the inode value for "/" and to consider whether it is reasonably low, but I would like a more accurate…
Topaz
  • 233
  • 1
  • 3
  • 8
21
votes
6 answers

execve file not found when stracing the very same file!

someone i know encountered a problem when running 'lmutil' so i asked them to strace -f lmutil. Why is execve failing with "No such file"!!! It makes no sense, since I am straceing the very same file!! What exactly is going on here??? strace -f…
user621819
1
2 3
33 34