Bu işe yaradı, değişiklik yapılacak satır numarasını bulup sed ile
değiştiriyorum:
For i in `cat users2.txt` ; do sed -i `grep -n ^$i: passwd | awk -F":" '{print
$1}'`'s/users/users2/g' passwd; done
From: [email protected]
[mailto:[email protected]] On Behalf Of Cemil KELES
Sent: Thursday, June 09, 2016 2:40 PM
To: Linux <[email protected]>
Subject: [Linux] Re: sed ile passwd düzenlemesi.
Merhaba,
`cat users2.txt` sonrası her bir satırı ayrı okumanız gerekir sanırım:
cat users2.txt | while read line
do
sed ....$line
done
şeklinde deneyebilir misiniz.
İyi çalışmalar
Cemil
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Taner KARAGÖL
Sent: Thursday, June 09, 2016 2:36 PM
To: Linux <[email protected]<mailto:[email protected]>>
Subject: [Linux] sed ile passwd düzenlemesi.
Merhaba;
Passswd dosyasında bazı kullanıcıların ev dizinlerini users->users2 şeklinde
değiştirmek istiyorum.
Bu komut tek kullanıcı için, örneğin karagol kullanıcısı için çalışıyor:
Sed -i 's/users\/karagol/users2\/karagol/g' passwd
Değişiklik yapılacak kullanıcı listesi users2.txt dosyasında, for döngüsü ile
sed çalışmıyor maalesef:
For i in `cat users2.txt` ; do sed -i 's/users\/$i/users2\/$i/g' passwd; done
Yaptığım yanlışlık nedir acaba. $i yerine ${i} "${i}" denedim ama yine olmadı.
Basit bir syntax hatası olmalı.
######################################################################
Dikkat:
Bu elektronik posta mesaji kisisel ve ozeldir. Eger size
gonderilmediyse lutfen gondericiyi bilgilendirip mesaji siliniz.
Firmamiza gelen ve giden mesajlar virus taramasindan gecirilmekte,
guvenlik nedeni ile kontrol edilerek saklanmaktadir. Mesajdaki
gorusler ve bakis acisi gondericiye ait olup Aselsan A.S. resmi
gorusu olmak zorunda degildir.
######################################################################
Attention:
This e-mail message is privileged and confidential. If you are
not the intended recipient please delete the message and notify
the sender. E-mails to and from the company are monitored for
operational reasons and in accordance with lawful business practices.
Any views or opinions presented are solely those of the author and
do not necessarily represent the views of the company.
######################################################################
_______________________________________________
Linux E-Posta Listesi
[email protected]
Liste kurallari: http://liste.linux.org.tr/kurallar.php
Bu Listede neden bulunduğunuzu bilmiyorsanız veya artık bu listeden gelen
e-postaları almak istemiyorsanız aşağıdaki bağlantı adresini kullanarak 1
dakika içinde üyeliğinizi sonlandırabilirsiniz.
https://liste.linux.org.tr/mailman/listinfo/linux