unix

sleep function in c, unix

南笙酒味 提交于 2020-02-01 04:53:20
问题 What do i need to import to use the sleep function in unix? i know it's windows.h for windows, but what about unix? 回答1: It should be in unistd.h. Please note that this gives you only a precision of integral seconds. The most portable way for sub-second precision should be (ab-)using select(). 回答2: #include <unistd.h> http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html 回答3: #include <unistd.h> THe man pages http://cis.kutztown.edu/~frye/cgi-bin/unixManPages.cgi?sleep+3C 来源:

Sorting date field in unix

房东的猫 提交于 2020-01-31 18:32:11
问题 I have text file which contains hundreds of thousands of records. One of the fields is a date field. Is there is any way to sort the file based on the date field? 09-APR-12 04.08.43.632279000 AM 19-MAR-12 03.53.38.189606000 PM 19-MAR-12 03.56.27.933365000 PM 19-MAR-12 04.00.13.387316000 PM 19-MAR-12 04.04.45.168361000 PM 19-MAR-12 03.54.32.595348000 PM 27-MAR-12 10.28.14.797580000 AM 28-MAR-12 12.28.02.652969000 AM 27-MAR-12 07.28.02.828746000 PM The Output should come as 19-MAR-12 03.53.38

Passing multiple arguments to a UNIX shell script

牧云@^-^@ 提交于 2020-01-31 18:26:09
问题 I have the following (bash) shell script, that I would ideally use to kill multiple processes by name. #!/bin/bash kill `ps -A | grep $* | awk '{ print $1 }'` However, while this script works is one argument is passed: end chrome (the name of the script is end) it does not work if more than one argument is passed: $end chrome firefox grep: firefox: No such file or directory What is going on here? I thought the $* passes multiple arguments to the shell script in sequence. I'm not mistyping

UNIX环境高级编程(第2版)

社会主义新天地 提交于 2020-01-31 09:02:19
UNIX环境高级编程(第2版) 是09年度畅销榜TOP50,08年度畅销榜TOP50 。 原书名: Advanced Programming in the UNIX Environment 原出版社: Addison-Wesley 作者: (美)W.Richard Stevens, Stephen A.Rago [作译者介绍] 译者: 尤晋元 张亚英 戚正伟 丛书名: 图灵计算机科学丛书 出版社:人民邮电出版社 本书是被誉为UNIX编程“圣经”的Advanced Programming in the UNIX Environment一书的第2版。对于所有层次UNIX/Linux程序员都是一本不可或缺的参考书。 下面介绍几个这本书的书评: 1、2005-12-02 14:59:39   来自: 刀巴 (签名党) UNIX环境高级编程的评论 5 虽然作者不幸离开了我们,虽然是本讲述Unix而不是Linux编程环境的书,虽然是一本有点历史的书。但是任何希望对 Unix/Linux系统有进一步的了解的人不能不读这本书。   纷繁复杂的Unix系统,在作者手下,若庖丁解牛,娓娓道来。同时,本书的翻译也颇为到位,技术名词准确,文章也没有生涩的感觉。 本书未提到的网络部分可以参见作者的另外几本书。   只是可惜作者没有对线程进行阐述,也许是英年早逝带给我们的遗憾吧。 2、2007-08-10

Shell variable is available on command line but not in script

眉间皱痕 提交于 2020-01-31 06:49:49
问题 In the bash command line, I set a variable myPath=/home/user/dir . I created a script in which I put echo $myPath but it doesnt seem to work. It echoes nothing. If I write echo $myPath in the command line, it works, but not in the script. What can I do to access the myPath variable in the script? 回答1: Export the variable: export myPath=/home/user/dir This instructs the shell to make the variable available in external processes and scripts. If you don't export the variable, it will be

When using vim or less in gnu screen, quitting vim or less leaves a lingering imprint

拟墨画扇 提交于 2020-01-31 04:33:58
问题 On my new Ubuntu system, I start a screen session and edit a file in vim or view it in less. After I quit, the screen doesn't redraw itself, but simply scrolls up to show a command line under all the stuff I was just viewing in vim or less. How can I change this so that quitting vim will return me to the screen the way it was before I invoked vim? 回答1: screen's altscreen (alternate screen) feature is turned off by default. Add this to your .screenrc : altscreen on See: http://www.gnu.org

Select a particular column using awk or cut or perl

纵饮孤独 提交于 2020-01-30 19:58:09
问题 I have a requirement to select the 7th column from a tab delimited file. eg: cat filename | awk '{print $7}' The issue is that the data in the 4th column has multiple values with blank in between. example - The last line in the below output: user \Adminis FL_vol Design 0 - 1 - group 0 FL_vol Design 19324481 - 3014 - user \MAK FL_vol Design 16875161 - 2618 - tree 826 FL_vol Out Global Doc Mark 16875162 - 9618 - /vol/FL_vol/Out Global Doc Mark 回答1: If the data is unambiguously tab-separated,

How to skip the cron job in saturday and sunday in linux? [closed]

妖精的绣舞 提交于 2020-01-30 14:20:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Hi I want to setup a cron job in linux excluding saturday and sunday. 回答1: Begin the line with 0 0 * * 1,2,3,4,5 <user> <command> . The first fields are minutes and hours. In this case the command will run at midnight. The stars mean: for every day of the month, and for every month. The 1 to 5 specify the days.

《Unix内核源码剖析》

北城以北 提交于 2020-01-30 11:39:19
《Unix内核源码剖析》 基本信息 作者: (日)青柳隆宏 译者: 殷中翔 丛书名: 图灵程序设计丛书 出版社:人民邮电出版社 ISBN:9787115345219 上架时间:2014-2-17 出版日期:2014 年3月 开本:16开 页码:1 版次:1-1 所属分类:计算机 更多关于》》》 《Unix内核源码剖析》 编辑推荐  精读1万行代码,深入理解操作系统原理!   超级计算机“京”的L1缓存设计者青柳隆宏经典著作!   彻底读懂Unix源代码! 内容简介 书籍 计算机书籍   《unix内核源码剖析》是一本unix v6内核源代码的阅读指南。作者结合unix v6已公开的相关文档,对unix v6的内核源码进行详细剖析,旨在让读者更深入地理解进程、中断、块i/o系统、文件系统、字符i/o系统、启动系统等操作系统的基本原理。   《unix内核源码剖析》适合操作系统的初中级学习者阅读,特别适合通过大学课程和其他入门书对操作系统有所了解,但是对具体细节缺乏深入理解的读者,以及那些对操作系统的具体实现有兴趣的读者。 目录 《unix内核源码剖析》 第i部分 什么是unix v6  1 第1章 unix v6的全貌  2 1.1  什么是unix  v6  2 1.2  unix的历史2 1.3  unix  v6内核  4 1.4  构成unix v6运行环境的硬件  4

storing the result of grep in a separate file

我与影子孤独终老i 提交于 2020-01-30 11:28:26
问题 I am searching something logs at the following directory $ cd opt/app/abc/logs Now the logs folder contains many different logs like abc.log def.log wer.log Now I need to search something in logs that I am doing n the following way as I wanted to know the names of the files first in which that entry is , Let say I am searching string 456 $bash $ cd opt/app/abc/logs $ grep -l 456 * now I also want that it should store all the records of string 456 in a separate text file at the same location