开发者

scripts on Cshell

开发者 https://www.devze.com 2023-01-01 09:17 出处:网络
I\'ve got some problem, I have list of data in the file: 053-37878 03828008 Moskovitch James 500 052-34363 01234567 Mendelson Kippi 450

I've got some problem, I have list of data in the file:

053-37878 03828008 Moskovitch James 500
052-34363 01234567 Mendelson Kippi 450
053-32322 03828008 Jameson Shula 350
054-39238 03333333 Merden Moshe 300

is it poss开发者_开发问答ible rewrite this list in the same file (without using temporary file) but without last number thanks in advance for any help (I'm talking about C-Shell scripts)


  1. Why do you need to avoid temporary files?

    cut -d " " -f 1,2,3 myfile > myfile2; mv myfile2 myfile
    
  2. You can also easily use Perl's -i switch to edit the file in place. It still creates a temp file under the covers, IIRC.

  3. If you need this for homework, use Perl to read the file into memory (File::Slurp), chop off last field using regex or somesuch; and write over the file from entire stored data using another File::Slurp

0

精彩评论

暂无评论...
验证码 换一张
取 消