solaris

Redirect output from sed 's/c/d/' myFile to myFile

放肆的年华 提交于 2019-12-17 18:36:44
问题 I am using sed in a script to do a replace and I want to have the replaced file overwrite the file. Normally I think that you would use this: % sed -i 's/cat/dog/' manipulate sed: illegal option -- i However as you can see my sed does not have that command. I tried this: % sed 's/cat/dog/' manipulate > manipulate But this just turns manipulate into an empty file (makes sense). This works: % sed 's/cat/dog/' manipulate > tmp; mv tmp manipulate But I was wondering if there was a standard way to

如何检查NaN值?

亡梦爱人 提交于 2019-12-17 16:07:02
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> float('nan') 结果为Nan(不是数字)。 但是,如何检查呢? 应该很容易,但是我找不到。 #1楼 好吧,我进入了这篇文章,因为我在功能上遇到了一些问题: math.isnan() 运行此代码时出现问题: a = "hello" math.isnan(a) 它引发异常。 我的解决方案是再次进行检查: def is_nan(x): return isinstance(x, float) and math.isnan(x) #2楼 我实际上只是碰到了这个,但是对我来说,它正在检查nan,-inf或inf。 我刚用过 if float('-inf') < float(num) < float('inf'): 这对于数字是正确的,对于nan和两个inf都是错误的,并且会为字符串或其他类型的东西引发异常(这可能是一件好事)。 同样,这不需要导入任何库,例如math或numpy(numpy是如此之大,它会使任何已编译应用程序的大小增加一倍)。 #3楼 如果卡在<2.6上,这是另一种方法,则没有numpy,并且没有IEEE 754支持: def isNaN(x): return str(x) == str(1e400*0) #4楼 随着python <2.6我最终得到了 def isNaN(x): return

How to use S_ISREG() and S_ISDIR() POSIX Macros?

为君一笑 提交于 2019-12-17 09:45:56
问题 This is a C program I wrote to recursively navigate and output directories and regular files. It compiles and runs fine on my Linux machine. But on Solaris, the dit->d_type == 8 check and the other similar ones don't work because there is no d_type field. An answer I've read to this problem is to use the S_ISREG() and S_ISDIR() macros, but they don't work at all the way I have them in my code currently. I commented out the lines that work on my Linux machine. #include <sys/types.h> #include

Alternative to `sed -i` on Solaris

我是研究僧i 提交于 2019-12-17 04:05:07
问题 On Linux sed -i will modify the input files in place. It doesn't work on Solaris, though. sed -i '$ s/OLD/NEW/g' test sed: illegal option -- i What can I use in place of sed -i on Solaris? 回答1: You'll need to replicate -i 's behavior yourself by storing the results in a temp file and then replacing the original file with the temp file. This may seem inelegant but that's all sed -i is doing under the covers. sed '$ s/OLD/NEW/g' test > test.tmp && cat test.tmp > test && rm test.tmp If you care

如何在nohup下放置已经运行的进程?

风格不统一 提交于 2019-12-16 18:22:39
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我有一个已经运行了很长时间并且不想结束它的进程。 我怎么把它放在nohup下(也就是说,即使关闭终端,如何让它继续运行?) #1楼 假设由于某种原因, Ctrl + Z也无法正常工作,转到另一个终端,找到进程ID(使用 ps )并运行: kill -SIGSTOP PID kill -SIGCONT PID SIGSTOP 将暂停该过程, SIGCONT 将在后台恢复该过程。 所以现在,关闭两个终端并不会停止你的过程。 #2楼 不幸的是, disown 特定于bash,并不适用于所有shell。 某些类型的Unix(例如AIX和Solaris)在 nohup 命令本身上有一个选项,可以应用于正在运行的进程: nohup -p pid 见 http://en.wikipedia.org/wiki/Nohup #3楼 这些都是上面的好答案,我只是想补充说明: 你不能 disown 一个pid或进程,你 disown 一份工作,这是一个重要的区别。 作业是附加到shell的进程的概念,因此您必须将作业放入后台(而不是暂停它),然后将其取消。 问题: % jobs [1] running java [2] suspended vi % disown %1 有关Unix作业控制的更详细讨论,请参见 http://www

UNIX 与 Linux 区别联系

久未见 提交于 2019-12-16 16:54:50
UNIX 与 Linux 区别联系 转载自: http://c.biancheng.net/view/707.html UNIX 与 Linux 之间的关系是一个很有意思的话题。在目前主流的服务器端操作系统中,UNIX 诞生于 20 世纪 60 年代末,Windows 诞生于 20 世纪 80 年代中期,Linux 诞生于 20 世纪 90 年代初,可以说 UNIX 是操作系统中的"老大哥",后来的 Windows 和 Linux 都参考了 UNIX。 现代的 Windows 系统已经朝着“图形界面”的方向发展了,和 UNIX 系统有了巨大的差异,从表面上甚至看不出两者的关联。 - UNIX 的坎坷历史 UNIX 操作系统由肯•汤普森(Ken Thompson)和丹尼斯•里奇(Dennis Ritchie)发明。它的部分技术来源可追溯到从 1965 年开始的 Multics 工程计划,该计划由贝尔实验室、美国麻省理工学院和通用电气公司联合发起,目标是开发一种交互式的、具有多道程序处理能力的分时操作系统,以取代当时广泛使用的批处理操作系统。 说明:分时操作系统使一台计算机可以同时为多个用户服务,连接计算机的终端用户交互式发出命令,操作系统采用时间片轮转的方式处理用户的服务请求并在终端上显示结果(操作系统将CPU的时间划分成若干个片段,称为时间片)。操作系统以时间片为单位

Is my Perl script grabbing environment variables from “someplace else”?

不羁的心 提交于 2019-12-14 03:55:49
问题 On a Solaris box in a "mysterious production system" I'm running a Perl script that references an environment variable. No big deal. The contents of that variable from the shell both pre- and post-execution are what I expect. However, when reported by the script, it appears as though it's running in some other sub-shell which is clobbering my vars with different values for the duration of the script. Unfortunately I really can't paste the code. I'm trying to get an atomic case, but I'm at my

Initial Heap size allocated to a C++ program on UNIX

眉间皱痕 提交于 2019-12-14 00:56:42
问题 What is the initial heap size alloted typically to a C++ program running on UNIX based OS ? How is it decided by the g++ compiler if at all it has a role to play in this regard ? 回答1: For C++, no matter what the platform, the heap is almost always extended dynamically by asking the OS for more memory as needed. On some embedded platforms, or some very old platforms this may not be true, but then you probably have a really good idea how much heap you have because of the nature of the

Solaris 8-10: host2ip conversion problems

喜夏-厌秋 提交于 2019-12-13 18:29:58
问题 I have a very peculiar problem that I am working on. I have code compiled by an old compiler (gcc 2.95 or older) on solaris 8/sparc platform. It runs fine on solaris 8/sparc but crashes on solaris 10/sparc. (solaris 10 is supposedly backward compatible with solaris 8) On debugging, I see that the problem comes up when the app tries to convert a hostname into it's corresponding i/p address. It uses gethostbyname_r, followed by inet_ntoa to obtain the ipv4 quad dotted number. gdb'ing through

get size of all shared memory segments

社会主义新天地 提交于 2019-12-13 16:33:00
问题 On Solaris it is possible to get with shmctl the size of a shared memory segment that I did not created and for which I don't have the permission ? For example I want to get the size of a segment created by another user with read-only mode for him only (600). I tried with the code below to get total size of all shared memory segments but I get a permission denied Cannot access shared memory information for segment 0 because Permission denied when I don't have read rights on a segment. int