Afficher un message
Vieux 21/03/2008, 04h56   #6
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: delete using sed and line number file ....



On 3/20/2008 10:28 AM, LionelAndJen@gmail.com wrote:
> I have file A with about 600 000 rows
> File B contains all the line numbers I need to delete, one line per
> file, 87 rows this time (could be 200 rows tomorrow)
>
> how do I use sed to delete each of the line from File A to create file
> C
>
> the manual command is simple and works perfectly:
>
> sed -e '5865d
> 7754d
> 12406d
> .
> .
> .
> 488596d
> 490322d
> 492259d
> 493646d' FileA >> FileC
>
> but I want to automate the process and sed gives me fits.


That's not what a good job for sed, but it's trivial in awk:

awk 'NR==FNR{skip[$0];next}!(FNR in skip)' FileB FileA > FileC

Ed.

  Réponse avec citation
 
Page generated in 0,05020 seconds with 9 queries