awk

Bash: Grab part of string from a command line output

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 19:38:41
问题 I am running a command in CentOS that gives me an output of a string and I want to grab a certain part of that output and set it to a variable. I run the command ebi-describe-env. My output as follows: ApplicationName | CNAME | DATECreated | DateUpdated | Description | EndpointURL | EnvironmentID | EnvironmentName | Health | Stack | Status | TemplateName | Version Label -------------------------- Web App | domain.com | 2012-02-23 | 2012-08-31 | | anotherdomain.com | e-8sgkf3eqbj | Web-App

awk -F not finding strings if AND condition is used

佐手、 提交于 2020-01-06 17:59:55
问题 I need to print second part of the searched string a="Hello I have a CREATE set TABLE as (uid, cid, mid)" Above string may continue as long as it needs. echo "$a" | awk -F"/CREATE/&&/TABLE/" '{print $2}' it returns nothing... It should return: as (uid, cid,mid) 回答1: Try this: echo "$a" | awk -F"CREATE.*TABLE" '{print $2}' as (uid, cid, mid) Not sure if regex in Field Separator do work. Using variable Field Separators: sep=two echo "_one_two_three_four" | awk -v var=$sep '{split($0,a,"_"var)

Awk replace string in line

大兔子大兔子 提交于 2020-01-06 17:57:09
问题 NOTE: This question looks like a previously posted one, but as mentioned in the comments, it turned out to be a chameleon question. I accepted the answer, and I'm posting here the same problem but with slightly different "solution conditions". I have a file test.txt like this (but containing many more lines) /foo/bar/how /SOME_TEXT_HERE/hello /foo/bar/are hello/SOME_OTHER_TEXT /foo/bar/you hello I want to get this output: /foo/bar/how /SOME_TEXT_HERE/how /foo/bar/are are/SOME_OTHER_TEXT /foo

awk/grep replace 2nd match after first match in text file while in foreach loop

Deadly 提交于 2020-01-06 15:21:50
问题 Okay I will try to describe my problem here. I have a file that looks like this: sta WP00 34.07335 -106.91932 1.43 time 10/23/2013 20:10:17 net XO datalogger Passcal_q330_linear 0100000EAA23E50F # 2847 sensor trillium_240_2 0 583 axis Z 0 0 - 1 1 axis N 0 90 - 2 1 axis E 90 90 - 3 1 samplerate 40sps channel Z BHZ 00 channel N BHN 00 channel E BHE 00 samplerate 1sps channel Z LHZ 00 channel N LHN 00 channel E LHE 00 add close sensor trillium_240_2 10/23/2013 20:10:17 sensor trillium_120 0 279

awk find if specific line exists between multiple common patterns

拈花ヽ惹草 提交于 2020-01-06 14:38:28
问题 I cant quite get my statements working as I need. I need to find if each of the patterns called Group contain the line FUNEnable within a config file. If its present then add a line after it within the file, if not then print a warning to screen. The could be any number of patterns called group as shown below: Sample file #config file <Some config> More config </Some config> #comment about FUNEnable Other config things <Group small.group> Something here FUNEnable Funfile /someplace/afunfile <

Translating character from a list to my file

女生的网名这么多〃 提交于 2020-01-06 14:10:28
问题 I have lots of files that look like this: 136 155 223 783 344 455 230 . . . And another file like this (the dictionary): rs6427315 230 rs1171564 455 rs1609666 344 rs728917 155 rs728918 223 rs11264495 783 rs11805559 136 . . . . . . And I want a new file that looks like this, that is reading the characters from my first file and substituting them with the match in column 1 from the other file: rs11805559 rs728917 rs728918 rs11264495 rs1609666 rs1609666 rs1171564 rs6427315 Thanks in advance 回答1:

Translating character from a list to my file

為{幸葍}努か 提交于 2020-01-06 14:10:12
问题 I have lots of files that look like this: 136 155 223 783 344 455 230 . . . And another file like this (the dictionary): rs6427315 230 rs1171564 455 rs1609666 344 rs728917 155 rs728918 223 rs11264495 783 rs11805559 136 . . . . . . And I want a new file that looks like this, that is reading the characters from my first file and substituting them with the match in column 1 from the other file: rs11805559 rs728917 rs728918 rs11264495 rs1609666 rs1609666 rs1171564 rs6427315 Thanks in advance 回答1:

Using mv command won't recognize * as wildcard

我的梦境 提交于 2020-01-06 12:42:49
问题 I have this script, and I know the awk command in it works, but when I want to save the output using the same name of the file it used to do the task using the mv command the * is not used as a wildcard but instead as a character and I end up with a file with a name like this: Algeria_BER_*_sites.txt The script: #!/bin/bash for i in Algeria_BER do echo awk 'FNR==NR{a[++i]=$0;next} {print a[FNR] RS $0}' \ reduced_filt_MAF_b37_chr1_${i}_ldhat.txt_names ${i}_*_sites.txt > $$.tmp && mv $$.tmp "$

AWK: Insert a row after each group of data

ぐ巨炮叔叔 提交于 2020-01-06 11:04:41
问题 I have a tab delimited csv file. The file is sorted by the column 6, which is the column that contains the key for each group. What I need is to insert a string after each group as a separator. Input: car camaleon queso cabra coche 531 cama leon lechuga dow click comedia clase tierno 531 falda camisa fiel rederdd black cama reloj visel 532 pila resto cena viento lamer viperest cash win 533 pale babe atun taza terron cabron fisgon dedo 533 one table deep black cama leona lechuga pies 534 blast

AWK: Insert a row after each group of data

和自甴很熟 提交于 2020-01-06 11:03:53
问题 I have a tab delimited csv file. The file is sorted by the column 6, which is the column that contains the key for each group. What I need is to insert a string after each group as a separator. Input: car camaleon queso cabra coche 531 cama leon lechuga dow click comedia clase tierno 531 falda camisa fiel rederdd black cama reloj visel 532 pila resto cena viento lamer viperest cash win 533 pale babe atun taza terron cabron fisgon dedo 533 one table deep black cama leona lechuga pies 534 blast