问题
My text file accommodates these lines:
Successfully started load asymmetric-song-851:bqjob_r069b9290_0000014bfebbdfa9_1
Successfully started load asymmetric-song-851:bqjob_r76eb714e_0000014bfebbf0de_1 BigQuery error in load operation: Error processing job 'asymmetric-song-851:bqjob_r7853a02a_0000014bfebc0247_1':
Not found: URI gs://brillio_buck/Week/game_activity_android_2015-01-23_to_2015-01-25.tsv
Some random text ...,,,, Some other random text
Successfully started load asymmetric-song-851:bqjob_r7d6c8bc3_0000014bfebc0d8f_1
Successfully started load asymmetric-song-851:bqjob_r110f9c79_0000014bfebc19fc_1
Successfully started load asymmetric-song-851:bqjob_r56873b54_0000014bfe9caeb7_1
Successfully started load asymmetric-song-851:bqjob_r0edb7092_0000014bfe9cbb8c_1
I want only jobids such as bqjob_r0edb7092_0000014bfe9cbb8c_1 in some other text file.So my output file should be as:
bqjob_r069b9290_0000014bfebbdfa9_1
bqjob_r76eb714e_0000014bfebbf0de_1
bqjob_r7853a02a_0000014bfebc0247_1
bqjob_r7d6c8bc3_0000014bfebc0d8f_1
bqjob_r110f9c79_0000014bfebc19fc_1
bqjob_r56873b54_0000014bfe9caeb7_1
bqjob_r0edb7092_0000014bfe9cbb8c_1
回答1:
You can use grep -o
:
grep -o 'bqjob_r[^[:blank:]]*_[0-9]' file
bqjob_r069b9290_0000014bfebbdfa9_1
bqjob_r76eb714e_0000014bfebbf0de_1
bqjob_r7853a02a_0000014bfebc0247_1
bqjob_r7d6c8bc3_0000014bfebc0d8f_1
bqjob_r110f9c79_0000014bfebc19fc_1
bqjob_r56873b54_0000014bfe9caeb7_1
bqjob_r0edb7092_0000014bfe9cbb8c_1
来源:https://stackoverflow.com/questions/28947240/batch-script-to-find-a-regex-in-a-text-file-and-write-it-line-by-line-in-another