-1

I would like to add login credentials

user: XXX ; pass:YYYY

as text line in all files of a given directory (as a string at the start of each file).

Also i would like to add this only in files with a certain extension .kkk

How can I do that? Thanks

AdminBee
  • 22,803
ECII
  • 101

1 Answers1

1

You can use sed or awk for that:

  • sed:
    sed '1i\user: XXX ; pass:YYY' *.kkk
    
  • awk:
    awk 'BEGIN{print "user: XXX ; pass:YYY"}1' *.kkk
    

In order to edit the files in-place, use the -i option for sed. For awk this only works since GNU awk version 4.1, when using the -i inplace option.

Update: This question has already answers here and here (and possibly others).

AdminBee
  • 22,803