Example of file.txt:/map/1.0.0/cd/base/4/23/82.png 200/map/1.0.0/cd/base/2/48/154.png?fefsfes 200/map/1.0.0/cd/base/3/45/433.png?gtdrdrg 200I need to delete this:.png.png?fefsfes.png?gtdrdrgI use this$ cat file.txt | awk '{ print $1,$2}'to get result:/map/1.0.0/cd/base/4/23/82.png,200/map/1.0.0/cd/base/2/48/154.png?fefsfes,200/map/1.0.0/cd/base/3/45/433.png?gtdrdrg,200Can I somehow fetch column with awk '{ print $1}' and delete everything after last number?Wanted result:/map/1.0.0/cd/base/4/23/82,200/map/1.0.0/cd/base/2/48/154,200/map/1.0.0/cd/base/3/45/433,200
How to delete/replace everything in column after certain character fetched with awk?
text processing;sed;awk
If you want to preserve the essence of your awk command, then you can simply sub away the unwanted trailing portion of $1awk '{sub(/\.png.*$/,,$1); print $1,$2}' fileor (perhaps more awkishly)awk '{sub(/\.png.*$/,,$1)}1' OFS=, file