unix

How do I grep for all words that are less than 4 characters?

99封情书 提交于 2021-02-07 09:59:18
问题 I have a dictionary with words separated by line breaks. 回答1: You can just do: egrep -x '.{1,3}' myfile This will also skip blank lines, which are technically not words. Unfortunately, the above reg-ex will count apostrophes in contractions as letters as well as hyphens in hyphenated compound words. Hyphenated compound words are not a problem at such a low letter count, but I am not sure whether or not you want to count apostrophes in contractions, which are possible (e.g., I'm). You can try

`fs.mkdir` is creating the directory with different permissions than those specified

怎甘沉沦 提交于 2021-02-07 08:01:53
问题 Due to the modules my node program uses, it requires root to run. This is because it has to run a HTTP server on port 80 (and as you know, lower ports like that require root in order to be used). But, this program also uses a fs method to create a file. I don't mind if root is the owner as long as I can change the permissions... But that's exactly where I'm hitting the bump. I'm using the fs.mkdir function to create a directory like so: (Lets say this file is named create.js ) fs.mkdir(_

`fs.mkdir` is creating the directory with different permissions than those specified

早过忘川 提交于 2021-02-07 08:01:37
问题 Due to the modules my node program uses, it requires root to run. This is because it has to run a HTTP server on port 80 (and as you know, lower ports like that require root in order to be used). But, this program also uses a fs method to create a file. I don't mind if root is the owner as long as I can change the permissions... But that's exactly where I'm hitting the bump. I'm using the fs.mkdir function to create a directory like so: (Lets say this file is named create.js ) fs.mkdir(_

`fs.mkdir` is creating the directory with different permissions than those specified

谁说胖子不能爱 提交于 2021-02-07 08:00:34
问题 Due to the modules my node program uses, it requires root to run. This is because it has to run a HTTP server on port 80 (and as you know, lower ports like that require root in order to be used). But, this program also uses a fs method to create a file. I don't mind if root is the owner as long as I can change the permissions... But that's exactly where I'm hitting the bump. I'm using the fs.mkdir function to create a directory like so: (Lets say this file is named create.js ) fs.mkdir(_

How to catch X errors?

眉间皱痕 提交于 2021-02-07 07:19:27
问题 I tried searching the web, but I must note that finding materials about this aspect of X programming is not really easy. I use X with GLX to create OpenGL contexts. I already know my current graphics card driver only supports up to OpenGL API version 3.3, but I want my application to be able to try to create a context with any kind of version (as it could run on other computers). My code goes like this : Version <- requested OpenGL Version (by example : 3.3) Create a context : if Version is 3

How to catch X errors?

隐身守侯 提交于 2021-02-07 07:19:18
问题 I tried searching the web, but I must note that finding materials about this aspect of X programming is not really easy. I use X with GLX to create OpenGL contexts. I already know my current graphics card driver only supports up to OpenGL API version 3.3, but I want my application to be able to try to create a context with any kind of version (as it could run on other computers). My code goes like this : Version <- requested OpenGL Version (by example : 3.3) Create a context : if Version is 3

Run shell script for every file in directory

◇◆丶佛笑我妖孽 提交于 2021-02-07 07:14:57
问题 I have a bunch of files in a directory all named YYYY_MM_DD -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_05 -rw-r--r-- 1 root root 483K Apr 21 13:17 2012_04_06 -rw-r--r-- 1 root root 484K Apr 21 13:17 2012_04_07 -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_08 -rw-r--r-- 1 root root 344K Apr 21 13:17 2012_04_09 -rw-r--r-- 1 root root 66K Apr 21 13:17 2012_04_10 -rw-r--r-- 1 root root 461K Apr 21 13:17 2012_04_11 -rw-r--r-- 1 root root 475K Apr 21 15:09 2012_04_17 -rw-r--r-- 1 root root

Run shell script for every file in directory

ぐ巨炮叔叔 提交于 2021-02-07 07:14:05
问题 I have a bunch of files in a directory all named YYYY_MM_DD -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_05 -rw-r--r-- 1 root root 483K Apr 21 13:17 2012_04_06 -rw-r--r-- 1 root root 484K Apr 21 13:17 2012_04_07 -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_08 -rw-r--r-- 1 root root 344K Apr 21 13:17 2012_04_09 -rw-r--r-- 1 root root 66K Apr 21 13:17 2012_04_10 -rw-r--r-- 1 root root 461K Apr 21 13:17 2012_04_11 -rw-r--r-- 1 root root 475K Apr 21 15:09 2012_04_17 -rw-r--r-- 1 root root

Python App ouput to syslog server

北慕城南 提交于 2021-02-07 06:56:48
问题 I'm trying to do some searching on google (looped for every 5 min or so). When it gets a hit I want it to push the results to a syslog server. I'm very new to python so please forgive the ignorance, I have searched for ages and can't find an answer to my question. I intend to add multiple queries looking for diffirent results depending on the query results the logevent differs. WARN "possible hit" CRITICAL "definatly a hit" etc I would like the output to be for example like: log type, url,

sorting with multiple keys with Linux sort command

与世无争的帅哥 提交于 2021-02-07 03:00:53
问题 Say I have this file. $ cat a.txt c 1002 4 f 1001 1 d 1003 1 a 1001 3 e 1004 2 b 1001 2 I want to sort it by the second column and then by the third column. Column two are numbers, while column 3 can be treated as string. I know the following command works well. $ sort -k2,2n -k3,3 a.txt f 1001 1 b 1001 2 a 1001 3 c 1002 4 d 1003 1 e 1004 2 However, I think sort -k2n a.txt should also work, while it does not. $ sort -k2n a.txt a 1001 3 b 1001 2 f 1001 1 c 1002 4 d 1003 1 e 1004 2 Seems like