|
Prev: html to ascii conversion: quick google translate from thecommand line
Next: Dalai Lama: your smiles charm but your actions harm
From: juhanay on 16 Apr 2008 08:17 Thanks for the replys. I noticed that my original spesification did contain two small mistakes. First of all the 00-section can contain any number (e.g 1, 12, 1234) not just 2-digits but it will contain atleast one digit. Another mistake was in the last section ZZZ, which contains four characters ZZZZ. Other than that the structure is fixed. Revised spesification 0+ XXX112233445566.QQQZZZZ I would need your help in choosing the best most universal way of doing this. We might import this code to many linux-machines and we would like to make it as portable as possible. So which one is better awk or sed? Or is there a third alternative?
From: Dave B on 16 Apr 2008 09:11 On Wednesday 16 April 2008 14:19, Maxwell Lol wrote: > sed ' > #duplicate the line first > /^.. \(...\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\.\(...\)\(...\)/p p -- D.
From: juhanay on 16 Apr 2008 09:04 Hi again The file is created by output from the command du (the exact command is given below). The idea is that there are many files with similar names and we just pick the latest one (generated dynamically by another program). Then we are interested in the file size (0+ field) and filename of that latest file, which we parse into different sections. QQQ-field is static and should always be the same. du -sk `ls *.QQQ???? -t | head -1` >file.txt After we have formed the file (with structure given above), then we need to parse it. So what is the best way then? Thanks again for the help.
From: pk on 16 Apr 2008 09:41 On Wednesday 16 April 2008 15:04, juhanay(a)gmail.com wrote: > Hi again > The file is created by output from the command du (the exact command > is given below). The idea is that there are many files with similar > names and we just pick the latest one (generated dynamically by > another program). Then we are interested in the file size (0+ field) > and filename of that latest file, which we parse into different > sections. QQQ-field is static and should always be the same. > > du -sk `ls *.QQQ???? -t | head -1` >file.txt > > After we have formed the file (with structure given above), then we > need to parse it. > > So what is the best way then? I assume the filesize would never exceed 9GB (which is probably the case). For maximum portability, I'd use sed and awk substr-based solutions. If you'll be using only linux, and file.txt will be small, then any solution among those proposed would just work fine. If the file.txt is going to be very large, and you'll be using linux, then the FIELDWIDTHS awk solution will probably be the most efficient. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome.
From: pk on 16 Apr 2008 09:48
On Wednesday 16 April 2008 15:41, pk wrote: > I assume the filesize would never exceed 9GB (which is probably the case). I mean the size of the *.QQQ???? file here. |