Home > Enterprise >  Add a new line with predefined data after each string in a txt document
Add a new line with predefined data after each string in a txt document

Time:12-22

This is how my txt document look like (an example);

asdf 
1234 
qwert 
56789 
zzzzz 
ccccc 

I want to add "STRING" in front each input, and a new line with "ENTER" after every input.

This is HOW I WANT it to look like;

STRING asdf 
ENTER 
STRING 1234 
ENTER 
STRING qwert 
ENTER 
...

I tried using the sed command in Linux, but my knowledge is limited.

I tried sed -e 's/$/ENTER/' -i pwdtest.txt but this dont write my "ENTER" keyword in a new line.

Im trying to make a rubber ducky script of a password list.

Please help me out solove this problem!

CodePudding user response:

Just use awk:

$ awk '{print "STRING", $0 ORS "ENTER"}' file
STRING asdf
ENTER
STRING 1234
ENTER
STRING qwert
ENTER
STRING 56789
ENTER
STRING zzzzz
ENTER
STRING ccccc
ENTER

CodePudding user response:

Using sed

$ sed 's/.*/&\nENTER/g' input_file
STRING asdf
ENTER
STRING 1234
ENTER
STRING qwert
ENTER
STRING 56789
ENTER
STRING zzzzz
ENTER
STRING ccccc
ENTER
  • Related