Skip to main content
added 287 characters in body
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

Using awk:

awk -v username='some username' -v line=32 'NR == line { $0 = $0 username } 1' file 

To insert the username into the middle of the line, one would have to know more about what the lines in the file looks like.

If the username and line are variables:

awk -v username="$username" -v line="$line" 'NR == line { $0 = $0 username } 1' file 

If you want to insert a space before the username:

awk -v username="$username" -v line="$line" 'NR == line { $0 = $0 " " username } 1' file 

Using awk:

awk -v username='some username' -v line=32 'NR == line { $0 = $0 username } 1' file 

To insert the username into the middle of the line, one would have to know more about what the lines in the file looks like.

Using awk:

awk -v username='some username' -v line=32 'NR == line { $0 = $0 username } 1' file 

To insert the username into the middle of the line, one would have to know more about what the lines in the file looks like.

If the username and line are variables:

awk -v username="$username" -v line="$line" 'NR == line { $0 = $0 username } 1' file 

If you want to insert a space before the username:

awk -v username="$username" -v line="$line" 'NR == line { $0 = $0 " " username } 1' file 
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

Using awk:

awk -v username='some username' -v line=32 'NR == line { $0 = $0 username } 1' file 

To insert the username into the middle of the line, one would have to know more about what the lines in the file looks like.