I want to do something like this:
echo "abc edg.txt" | awk -F. '{print $0"---"$1}'
I expect the result should be:
abc edg—txt
but it turns out to be:
abc edg.txt—abc edg
What is causing this behavior, and how can I fix my code to produce the output that I expect?
In awk,
$0evaluates to the whole record, and field indexes are one-based.You probably want to do: