cut

Parse through JSON using only Bash [duplicate]

家住魔仙堡 提交于 2019-12-25 16:08:28
问题 This question already has answers here : Parsing JSON with Unix tools (36 answers) Closed last year . I have a JSON file : { "request_id": "9a081c0c-9401-7eca-f55d-50e3b7c0301c", "lease_id": "", "renewable": false, "lease_duration": 2764800, "data": { "password": "test123", "username": "testuser1" }, "wrap_info": null, "warnings": null, "auth": null } I am trying to read the values of username and password . Now I was able to integrate bash and python to get what I wanted. # curl --silent -k

Parse through JSON using only Bash [duplicate]

旧城冷巷雨未停 提交于 2019-12-25 16:08:11
问题 This question already has answers here : Parsing JSON with Unix tools (36 answers) Closed last year . I have a JSON file : { "request_id": "9a081c0c-9401-7eca-f55d-50e3b7c0301c", "lease_id": "", "renewable": false, "lease_duration": 2764800, "data": { "password": "test123", "username": "testuser1" }, "wrap_info": null, "warnings": null, "auth": null } I am trying to read the values of username and password . Now I was able to integrate bash and python to get what I wanted. # curl --silent -k

How do I transfer wget output to a file or DB?

北战南征 提交于 2019-12-25 11:26:56
问题 I'm trying to use a small script to download a field from multiple pages. For one thing, I'm only able to get it from one page..., but the real problem I'm having is that I don't know how to hand the output off to a database table? How can I take the output from curl/lynx|grep (which is going to be all the list items) and move it, list item by list item, to a table in my DB or to a CSV where it will be ready for import to the DB? #!/bin/bash lynx --source "http://www.thewebsite.com"|cut -d\"

How do I transfer wget output to a file or DB?

廉价感情. 提交于 2019-12-25 11:26:56
问题 I'm trying to use a small script to download a field from multiple pages. For one thing, I'm only able to get it from one page..., but the real problem I'm having is that I don't know how to hand the output off to a database table? How can I take the output from curl/lynx|grep (which is going to be all the list items) and move it, list item by list item, to a table in my DB or to a CSV where it will be ready for import to the DB? #!/bin/bash lynx --source "http://www.thewebsite.com"|cut -d\"

How to get ordered, defined or all columns except or after or before a given column

孤人 提交于 2019-12-25 10:50:59
问题 In BASH I run the following one liner to get an individual column/field after splitting on a given character (one can use AWK as well if they want to split on more than one char i.e. on a word in any order, ok). #This will give me first column i.e. 'lori' i.e. first column/field/value after splitting the line / string on a character '-' here echo "lori-chuck-shenzi" | cut -d'-' -f1 # This will give me 'chuck' echo "lori-chuck-shenzi" | cut -d'-' -f2 # This will give me 'shenzi' echo "lori

How to get ordered, defined or all columns except or after or before a given column

我的梦境 提交于 2019-12-25 10:50:17
问题 In BASH I run the following one liner to get an individual column/field after splitting on a given character (one can use AWK as well if they want to split on more than one char i.e. on a word in any order, ok). #This will give me first column i.e. 'lori' i.e. first column/field/value after splitting the line / string on a character '-' here echo "lori-chuck-shenzi" | cut -d'-' -f1 # This will give me 'chuck' echo "lori-chuck-shenzi" | cut -d'-' -f2 # This will give me 'shenzi' echo "lori

How to cut data in even pieces in R? [duplicate]

点点圈 提交于 2019-12-25 08:34:40
问题 This question already has answers here : Split a vector into chunks in R (20 answers) Closed 6 years ago . Here is the problem: I have a dataset, let's say: a <- c(0,0,0,0,1,1,1,1,1,1) I want to cut it into even pieces (e.g. 5 pieces ). The problem is I cannot use quantiles or cut because some values repeat, so you cannot set distinct breakpoints. > quantile(a) 0% 25% 50% 75% 100% 0 0 1 1 1 (repeated breakpoints) > cut(a, 5) [1] (-0.001,0.199] (-0.001,0.199] (-0.001,0.199] (-0.001,0.199] (0

Use awk to print first column, second column and one column every four after that

寵の児 提交于 2019-12-25 06:58:29
问题 I have a text file and I want to extract the first column, second column and one column every 3 after that. Also, I want to get rid of row #2. How can I do that using awk or similar? An example: I have a text file as such: A B C D E F G H I J .. N (header 1) A B C D E F G H I J .. N (header 2) A B C D E F G H I J .. N (row 1) A B C D E F G H I J .. N (row 2) A B C D E F G H I J .. N (row n) I'm trying to get it as A B F J .. N (header 1) A B F J .. N (row 1) A B F J .. N (row 2) A B F J .. N

Override iPhone copy menu captions on a long-press?

房东的猫 提交于 2019-12-25 04:55:29
问题 Is it possible to override the captions in the "Copy" menu when the iphone user long-presses on some text? Essentially, I'd like to change the text to something like "Create a Note" instead of "Copy". Is that possible? 回答1: You can add custom menus via UIMenuController's menuItems property, something like: UIMenuItem* item1 = [[UIMenuItem alloc] initWithTitle:@"One" action:@selector(DoThingOne:)]; UIMenuItem* item2 = [[UIMenuItem alloc] initWithTitle:@"Two" action:@selector(DoThingTwo:)];

Bash oneliner with AWK runs in terminal but not in script

空扰寡人 提交于 2019-12-25 02:43:24
问题 I have a file with the following type of data: 4-11-11 12:59:01,C,26,668 4-11-11 12:59:31,C,26,668 4-11-11 13:00:01,C,26,668 4-11-11 13:00:31,C,26,668 4-11-11 13:01:01,C,26,668 4-11-11 13:01:31,C,26,668 and I want the following output: 12:59:01 26.668 12:59:31 26.668 13:00:01 26.668 13:00:31 26.668 13:01:01 26.668 13:01:31 26.668 This works just fine in the termal with the following line, but not in a bash script, it just gives me an empty file. The problem started after I added the awk part.