faylning har bir satridan keyin qo'shimcha qatorlarni qo'shing

faylning har bir satridan keyin qo'shimcha qatorlarni qo'shing

Taxminan 1000 satr fayli uchun quyidagi vazifalar uchun yordamga muhtojman.

KIRITISH

    ./create.pl     1eaj.out
    ./create.pl     1ezg.out
    ./create.pl     1f41.out
    ...

OUTPUT

    ./create.pl     1eaj.out
    mv complex.* 1eaj
    ./create.pl     1ezg.out
    mv complex.* 1ezg
    ./create.pl     1f41.out
    mv complex.* 1f41
    ...

Quyidagi buyruqlar yangi chiziqni va birinchi qismni quyi kabi chiqara oladigan tarzda qo'shishi mumkinligini bilaman.

    awk ' {print;} NR % 1 == 0 { print "mv complex.*  "; }'

    ./create.pl     1eaj.out
    mv complex.* 
    ./create.pl     1ezg.out
    mv complex.* 
    ./create.pl     1f41.out
    mv complex.* 
    ...

Qolganini qanday qilish kerak? Oldindan katta rahmat.

1
Sizga kerakli narsalarni olish uchun ko'chadan yozishni ko'rib chiqishingiz mumkin.
qo'shib qo'ydi muallif Bernhard, manba

7 javoblar

Siz deyarli u erda edingiz:

$ awk '{print $1, $2, "\nmv complex.*", $2}' file
./create.pl 1eaj.out 
mv complex.* 1eaj.out
./create.pl 1ezg.out 
mv complex.* 1ezg.out
./create.pl 1f41.out 
mv complex.* 1f41.out
3
qo'shib qo'ydi

Siz deyarli u erda edingiz:

$ awk '{print $1, $2, "\nmv complex.*", $2}' file
./create.pl 1eaj.out 
mv complex.* 1eaj.out
./create.pl 1ezg.out 
mv complex.* 1ezg.out
./create.pl 1f41.out 
mv complex.* 1f41.out
3
qo'shib qo'ydi

Siz deyarli u erda edingiz:

$ awk '{print $1, $2, "\nmv complex.*", $2}' file
./create.pl 1eaj.out 
mv complex.* 1eaj.out
./create.pl 1ezg.out 
mv complex.* 1ezg.out
./create.pl 1f41.out 
mv complex.* 1f41.out
3
qo'shib qo'ydi

Mening harakatim:

sed -n 's/^\(\.\/create\.pl\)\s*\(.*\)\.out$/\1 \2.out\nmv complex.* \2/p' s.txt

or using && between ./create.pl and mv (since mv is likely needed only when ./create.pl is correctly executed):

sed -n 's/^\(\.\/create\.pl\)\s*\(.*\)\.out$/\1 \2.out \&\& mv complex.* \2/p' s.txt

bu quyidagilarni beradi:

./create.pl 1eaj.out && mv complex.* 1eaj
./create.pl 1ezg.out && mv complex.* 1ezg
./create.pl 1f41.out && mv complex.* 1f41
3
qo'shib qo'ydi
Vau skwllsp. Katta rahmat. U yaxshi ishlaydi.
qo'shib qo'ydi muallif user2176228, manba

Kerakli so'zni chiqarib olish uchun bo'shliq yoki nuqta-dan foydalaning:

awk -F '[[:blank:].]+' '{print; print "mv complex.*", $4}' filename
2
qo'shib qo'ydi

Kerakli so'zni chiqarib olish uchun bo'shliq yoki nuqta-dan foydalaning:

awk -F '[[:blank:].]+' '{print; print "mv complex.*", $4}' filename
2
qo'shib qo'ydi

Kerakli so'zni chiqarib olish uchun bo'shliq yoki nuqta-dan foydalaning:

awk -F '[[:blank:].]+' '{print; print "mv complex.*", $4}' filename
2
qo'shib qo'ydi
Python
Python
372 ishtirokchilar

Bu guruh python dasturlash tilini muhokama qilish uchun. Iltimos, o'zingizni hurmat qiling va faqat dasturlash bo'yicha yozing. Botlar mavzusini @botlarhaqida guruhida muhokama qling! FAQ: @PyFAQ Offtopic: @python_uz_offtopic

Python offtopic group !
Python offtopic group !
150 ishtirokchilar

@python_uz gruppasining offtop gruppasi. offtop bo'lsa ham reklama mumkin emas ) Boshqa dasturlash tiliga oid gruppalar @languages_programming