Search code examples
programming-languagesscriptingcshtcsh

scripts on Cshell


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 possible 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)


Solution

    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