![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| file command | rprajendran | UNIX for Advanced & Expert Users | 3 | 05-13-2008 10:45 AM |
| rm command not able to remove file | jambesh | Shell Programming and Scripting | 7 | 12-21-2007 03:37 AM |
| What is the command to add heading to a file? | whatisthis | UNIX for Dummies Questions & Answers | 3 | 12-01-2005 11:17 PM |
| End of file using more command | Enda Martin | UNIX for Dummies Questions & Answers | 3 | 06-18-2001 07:49 AM |
| for file in ???? - command | tamer | UNIX for Dummies Questions & Answers | 10 | 01-31-2001 05:40 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
VI command for File Please
I have a file with numbers like:
2235900 2234500 2220000 22300 235700 2200 0 and I need a search and replace to change the number to a 3 place decimal... like this : 2235.900 2234.500 2220.000 22.300 235.700 2.200 .000 Can someone please help me with the command I need to use in the VI editor to get these results of a file that has 3724 lines of numbers I need to make into 3 place decimal numbers? Thanks so much. |
| Forum Sponsor | ||
|
|
|
|||
|
I dont think you can do this in VI. Unless someone who knows vi macros can knock something together .... if you only have 1 number per line and you dont mind 0.000 instead of .000 then the following will work:
perl -e 'while($line=<>) { printf ("%.3f\n",($line/1000));}' inputfile.txt > outputfile.txt Or if you had multiple numbers on each line then maybe: perl -e 'while($line=<>){$line =~ s{(\d+)}{sprintf("%.3f",$1/1000)}eg; print "$line";}' inputfile.txt > outputfile.txt Last edited by vgersh99; 08-31-2005 at 01:26 PM. |
|
|||
|
Quote:
get Perl loaded and give this a try.... running windoz ... would really like to get back to the REAL OS but have too many apps that only run under windoz Thanks, |
|
|||
|
Quote:
" > was unexpected at this time. " when I try this command at a command prompt. Any suggestions? |