Skip to main content
copy OP clarification about the input file separator from the comment into body ; edited tags
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

I just want to modify the second column "Name" and remove all the spaces from between the name and leave the rest of the txt file untouched and further, print it.

Here is my input (Tab separated fields):

Roll NO Name         RandomColumn1    RandomColumn2 
1       Jason James  my value        my val 3

My Desired output:

Roll NO Name        RandomColumn1  RandomColumn2 
1       JasonJames  my value        my val 3

Command that I had been using but been unsuccessful with:

 awk '{$3=$4;  print }' | sed "s/^ *//"

I just want to modify the second column "Name" and remove all the spaces from between the name and leave the rest of the txt file untouched and further, print it.

Here is my input:

Roll NO Name         RandomColumn1    RandomColumn2 
1       Jason James  my value        my val 3

My Desired output:

Roll NO Name        RandomColumn1  RandomColumn2 
1       JasonJames  my value        my val 3

Command that I had been using but been unsuccessful with:

 awk '{$3=$4;  print }' | sed "s/^ *//"

I just want to modify the second column "Name" and remove all the spaces from between the name and leave the rest of the txt file untouched and further, print it.

Here is my input (Tab separated fields):

Roll NO Name         RandomColumn1    RandomColumn2 
1       Jason James  my value        my val 3

My Desired output:

Roll NO Name        RandomColumn1  RandomColumn2 
1       JasonJames  my value        my val 3

Command that I had been using but been unsuccessful with:

 awk '{$3=$4;  print }' | sed "s/^ *//"
Source Link
James
  • 31
  • 1
  • 3

How to remove spaces from specific column using awk

I just want to modify the second column "Name" and remove all the spaces from between the name and leave the rest of the txt file untouched and further, print it.

Here is my input:

Roll NO Name         RandomColumn1    RandomColumn2 
1       Jason James  my value        my val 3

My Desired output:

Roll NO Name        RandomColumn1  RandomColumn2 
1       JasonJames  my value        my val 3

Command that I had been using but been unsuccessful with:

 awk '{$3=$4;  print }' | sed "s/^ *//"