Jump to content

Recommended Posts

salut, am text asa:

 

11111111111111111111;X32rrsdcsdafs3242sdfsf

22222222222222222222;Lq4qdaasdaadkaoaaoasd

33333333333333333333;H141asd;asdalsjdaldajda

 

vreau sa il fac asa:

11111111111111111111

X32rrsdcsdafs3242sdfsf

22222222222222222222

Lq4qdaasdaadkaoaaoasd

33333333333333333333

H141asd;asdalsjdaldajda

 

am incercat google, tutoriale etc , ma bate rau regex in notepad ++

va rog daca cineva are timp sa ma ajute, multumesc anticipat.

Share this post


Link to post
Share on other sites

Doar de curiozitate am incercat asta. Echivalentul a ce e mai sus, din gnu utils. Functional pe WSL, ca sa nu-mi sara lumea-n cap.

λ for i in {1..100000}; do echo "1$((RANDOM))1;2$((RANDOM))2" >> foo.txt; done
λ wc -l foo.txt 
100000 foo.txt
λ head -5 foo.txt 
1115171;2177222
1141431;236462
196431;2104792
183611;2123182
1290431;2181642

# inline sed
λ time sed -i 's/;/\n/' foo.txt
sed -i 's/;/\n/' foo.txt  0.03s user 0.00s system 99% cpu 0.026 total

# tr
λ time (cat foo.txt | tr ';' '\n' | tee foo.txt)
( cat foo.txt | tr ';' '\n' | tee foo.txt; )  0.00s user 0.03s system 64% cpu 0.045 total

# awk
λ time (cat foo.txt | awk -F ';' '{print $1 "\n" $2}' | tee foo.txt)
( cat foo.txt | awk -F ';' '{print $1 "\n" $2}' | tee foo.txt; )  0.01s user 0.01s system 129% cpu 0.016 total

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...