Below is a input.
!{ID=34, ID2=35} > !{ID=99, ID2=23} > !{ID=18, ID2=87} < I am trying to make a final result like as following. That is, wanted to remove space,'{' and '}' character and check if the next line is '>' or '<'. In fact, the input above is repeated. I also need to parse '>' and '<' character so I will put the parsed string(YES or NO) into database.
ID=34,ID=35#YES#NO ID=99,ID=23#YES#NO ID=18,ID=87#NO#YES So, with 'sub' function I thought I can replace the space with blank but the result shows:
1#YES#NO
Can you let me know what is wrong? If possible, teach me how to remove '{' and '}' as well. Appreciated if you could show me the awk file version instead of one-liner.
BEGIN { VALUES = "" L_EXIST = "NO" R_EXIST = "NO" } /!/ { VALUES = gsub(" ", "", $0); getline; if ($1 == ">") L_EXIST = "YES"; else if ($1 == "<") R_EXIST = "YES"; print VALUES"#"L_EXIST"#"R_EXIST } END { }
echo '!{ID=34, ID2=35}' | tr -d '[!{ }]'returnsID=34,ID2=35(-dto delete and then a set of characters). Not sure what the extra#YES#NOmeans.'>'are new - are they supposed to be there? What would the corresponding output be for those lines of input?