I have this value, cutted from .txt:
,Request Id,dummy1,dummy2,dummyN
I am trying to find and replace the space with "_", like this:
#iterator to read lines of txt
#if conditions
trim_line=$(echo "$user" | awk '{gsub(" ", "_", $0); print}')
echo $trim_line
but the echo is showing:
Id,dummy1,dummy2,dummyN
Expected output:
,Request_Id,dummy1,dummy2,dummyN
Where is my bug?
EDIT: The echo of user is not the expected, it is:
Id,dummy1,dummy2,dummyN
And should be:
,Request Id,dummy1,dummy2,dummyN
To do this operation I am using:
for user in $(cut -d: -f1 $FILENAME)
do (....) find/replace
,Request_Id,dummy1,dummy2,dummyN$userdoesn't contain what you expect.echo $user?troverawk, it looks like this is not your current problem :echo ",Request Id,dummy1,dummy2,dummyN" | awk '{gsub(" ", "_", $0); print}'correctly outputs,Request_Id,dummy1,dummy2,dummyN