awk

How to delete all lines before the first and after the last occurrence of a string?

纵然是瞬间 提交于 2021-01-02 06:00:26
问题 cat grab.txt My Dashboard Fnfjfjf. random test 00:50 1:01:56 My Notes No data found. Change Language + English Submit Estimation of Working Capital Lecture 1 Estimation of Working Capital Lecture 2 Estimation of Working Capital Lecture 3 Money Market Lecture 254 Money Market Lecture 255 Money Market Lecture 256 International Trade Lecture 257 International Trade Lecture 258 International Trade Lecture 259 Terms And Conditions 84749473837373 Random text fifjfofifofjfkfkf I need to filter this

How can I combine odd and even numbered lines?

戏子无情 提交于 2020-12-29 10:07:12
问题 I want to combine every even-numbered line with the line above it. Something like: Line one,csv,csv,csv Line two,csv,csv Line three,csv,csv,csv,csv Line four,csv The result should look like this: Line one,csv,csv,csv,Line two,csv,csv Line three,csv,csv,csv,csv,Line four,csv Any ideas how to achieve that in either Perl or sed/awk? 回答1: Perl's builtin variable $. will tell you the line number. $. % 2 will be 1 if $. is odd, and 0 otherwise. Here is a self-contained example; #!/usr/bin/perl use

How can I combine odd and even numbered lines?

本秂侑毒 提交于 2020-12-29 10:05:42
问题 I want to combine every even-numbered line with the line above it. Something like: Line one,csv,csv,csv Line two,csv,csv Line three,csv,csv,csv,csv Line four,csv The result should look like this: Line one,csv,csv,csv,Line two,csv,csv Line three,csv,csv,csv,csv,Line four,csv Any ideas how to achieve that in either Perl or sed/awk? 回答1: Perl's builtin variable $. will tell you the line number. $. % 2 will be 1 if $. is odd, and 0 otherwise. Here is a self-contained example; #!/usr/bin/perl use

How can I combine odd and even numbered lines?

流过昼夜 提交于 2020-12-29 10:04:28
问题 I want to combine every even-numbered line with the line above it. Something like: Line one,csv,csv,csv Line two,csv,csv Line three,csv,csv,csv,csv Line four,csv The result should look like this: Line one,csv,csv,csv,Line two,csv,csv Line three,csv,csv,csv,csv,Line four,csv Any ideas how to achieve that in either Perl or sed/awk? 回答1: Perl's builtin variable $. will tell you the line number. $. % 2 will be 1 if $. is odd, and 0 otherwise. Here is a self-contained example; #!/usr/bin/perl use

process data from text file and convert into csv

我的梦境 提交于 2020-12-27 06:34:27
问题 In our organization, every month a few jobs will run and collect data on server level and it will find what is running on the server and also perform some checks. These files are text files and copied to one repository server. The file name will be <servername>_20200911.log This sample file checks for servers where postgreSQL is running. Date Collected || 11-10-2020 03:20:42 GMT || Server Name || pglinux1 || Operating system || RHEL || passed OS Version || 6.9 || passed Kernel version || 2.6

moving sql logic to backend - bash

无人久伴 提交于 2020-12-27 05:51:26
问题 One of the sql logic is moving to backend and I need to generate a report using shell scripting. For understanding, I'm making it simple as follows. My input file - sales.txt (id, price, month) 101,50,2019-10 101,80,2020-08 101,80,2020-10 201,100,2020-09 201,350,2020-10 The output should be for 6 months window for each id e.g t1=2020-07 and t2=2020-12 101,50,2020-07 101,80,2020-08 101,80,2020-09 101,80,2020-10 101,80,2020-11 101,80,2020-12 201,100,2020-09 201,350,2020-10 201,350,2020-11 201

moving sql logic to backend - bash

十年热恋 提交于 2020-12-27 05:50:46
问题 One of the sql logic is moving to backend and I need to generate a report using shell scripting. For understanding, I'm making it simple as follows. My input file - sales.txt (id, price, month) 101,50,2019-10 101,80,2020-08 101,80,2020-10 201,100,2020-09 201,350,2020-10 The output should be for 6 months window for each id e.g t1=2020-07 and t2=2020-12 101,50,2020-07 101,80,2020-08 101,80,2020-09 101,80,2020-10 101,80,2020-11 101,80,2020-12 201,100,2020-09 201,350,2020-10 201,350,2020-11 201

moving sql logic to backend - bash

*爱你&永不变心* 提交于 2020-12-27 05:50:02
问题 One of the sql logic is moving to backend and I need to generate a report using shell scripting. For understanding, I'm making it simple as follows. My input file - sales.txt (id, price, month) 101,50,2019-10 101,80,2020-08 101,80,2020-10 201,100,2020-09 201,350,2020-10 The output should be for 6 months window for each id e.g t1=2020-07 and t2=2020-12 101,50,2020-07 101,80,2020-08 101,80,2020-09 101,80,2020-10 101,80,2020-11 101,80,2020-12 201,100,2020-09 201,350,2020-10 201,350,2020-11 201

How to execute (./myscript) inside awk or bash script?

妖精的绣舞 提交于 2020-12-26 11:04:20
问题 I would like to run a script within an awk command. I have a code ./myscript that calculates the likelihood between two entities; the results are listed in listfile.txt. The input for ./myscript is a file with two columns generated randomly. The purpose here is to know what input file (values) is the best for the calculation. If the condition (0.01<$8<0.5) is not verified, the code keep running until it gives the best (random input) I did try this, but it doesn't keep executing the code .

Awk RegEx returning nada?

允我心安 提交于 2020-12-15 06:44:24
问题 So I have this text in a file named version.php : <?php $OC_Version = array(20,0,1,1); $OC_VersionString = '20.0.1'; $OC_Edition = ''; $OC_Channel = 'stable'; $OC_VersionCanBeUpgradedFrom = array ( 'nextcloud' => array ( '19.0' => true, '20.0' => true, ), 'owncloud' => array ( ), ); $OC_Build = '2020-10-24T08:39:55+00:00 89d88b3ea5b4049355e3c49d121f82e5e62bfc44'; $vendor = 'nextcloud'; and I'm trying to get awk to return just the version number from the line: $OC_VersionString = '20.0.1';