There is some code
AGENT=`/usr/sbin/tcpdump -nl -s 0 -A -r $FNAME 2>&1 | strings | grep -i "User-Agent:"` as a result of which I get a variable with the contents of http://pastebin.com/NHZfxQeW Next, I want to parse all of this, so that using echo output each user agent to the console line by line and do this:
FORMATTED_AGENT=$(echo "$AGENT"|tr "User-Agent:" "\n"|sort -u) for i in $FORMATTED_AGENT; do echo $i; done those. I want to replace the words User-Agent: with the service symbol of the beginning of a new line, but I get the error tr: неверный порядок границ диапазона «rA» . With the help of sed it also does not work - it is still molded into one line but already in $FORMATTED_AGENT
Question : How to do it correctly if one of the conditions of the problem is non-use of temporary files (well, of the type to write line by line initially to a temporary file and cat to read it)?
The point is to line up line by line what we put in $AGENT but without using anything (such as temporary files). I just don’t know any other way than replacing the duplicate User-Agent: with the start of a line, but maybe you know?
sed? It's clear withtr, it's not his job to change words, it works with symbols - Mikesedresult (the whole variable) was printed that in it was Miketr- also with symbols. I have the variable $ HER = "1, 2, 3, 4, 5, 6," and so if you try to replace thetr'comma with\n- the same thing happens - nothing, it just cuts out the comma. - user238861