Add new uuid to each line of a file using sed or equivalent command

前端 未结 3 1430
说谎
说谎 2021-01-27 02:19

I\'ve got a multi line text file that I want to use to create an SQL statement that requires a UUID. I\'m attempting to come up with a way to generate the SQL using sed or some

3条回答
  •  太阳男子
    2021-01-27 02:25

    sed 's/.*/echo "`uuidgen`,&"/e' input |
        sed -r 's/(.*),(.*)/insert into table values("\1","\2");/' |
            tr '"' "'"
    

    insert into table values('c609f5ab-28ce-4853-bd67-7b6b4ca13ee3','A');
    insert into table values('01ae6480-1b52-49a8-99a3-f2bba7ec3064','B');
    insert into table values('a41122e8-5e4f-4acc-b62a-bc4ad629677e','C');
    

提交回复
热议问题