find -ls field separator

This is a discussion on find -ls field separator within the shell forums in Operating Systems category; Hi all, I am using AIX 5.2 and 5.3 and have to do data migration from old machine to new machine. After migration, I have to do verification. There is a very quick and dirty verification is to ensure the filesize is the same after the migration. The method is very simple: find MyDirectory -type f -ls | awk '{print $11, $7}' To produce a report in both the old and new machine and then use the join command to let the filename (i.e. $11) as key and then compare the 2 filesize values (i.e. $7) This ...

Go Back   Database Forum > Operating Systems > shell

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-28-2008, 07:06 AM
Default find -ls field separator

Hi all,

I am using AIX 5.2 and 5.3
and have to do data migration from old machine to new machine.

After migration, I have to do verification.

There is a very quick and dirty verification
is to ensure the filesize is the same after the migration.

The method is very simple:
find MyDirectory -type f -ls | awk '{print $11, $7}'

To produce a report in both the old and new machine
and then use the join command to
let the filename (i.e. $11) as key
and then compare the 2 filesize values (i.e. $7)

This work for 99.9%
except when the filename contain SPACE or SPACES.

My question is:
Can the find -ls
command use TAB or other non-space character
as the field separator ?

If not, any idea to solve this problem ?

Hmmmmm, the filename-with-space is really a headache to me
for many many times
but I have no choice !

Thanks in advance.
Alvin SIU
Reply With Quote
  #2  
Old 08-28-2008, 07:25 AM
Default Re: find -ls field separator

On Thursday 28 August 2008 12:06, Alvin SIU wrote:

> Hi all,
>
> I am using AIX 5.2 and 5.3
> and have to do data migration from old machine to new machine.
>
> After migration, I have to do verification.
>
> There is a very quick and dirty verification
> is to ensure the filesize is the same after the migration.
>
> The method is very simple:
> find MyDirectory -type f -ls | awk '{print $11, $7}'
>
> To produce a report in both the old and new machine
> and then use the join command to
> let the filename (i.e. $11) as key
> and then compare the 2 filesize values (i.e. $7)
>
> This work for 99.9%
> except when the filename contain SPACE or SPACES.
>
> My question is:
> Can the find -ls
> command use TAB or other non-space character
> as the field separator ?


I don't know, but you can of course change your awk program.
For example:

find MyDirectory -type f -ls | \
awk '{s=$7;sub(/^([^[:space:]]*[[:space:]]*){10}/,"");print $0,s}'


--
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.
Reply With Quote
  #3  
Old 08-28-2008, 09:09 AM
Default Re: find -ls field separator

Alvin SIU wrote:
>
> I am using AIX 5.2 and 5.3
> and have to do data migration from old machine to new machine.
>
> After migration, I have to do verification.
>
> There is a very quick and dirty verification
> is to ensure the filesize is the same after the migration.
>
> The method is very simple:
> find MyDirectory -type f -ls | awk '{print $11, $7}'
>
> To produce a report in both the old and new machine
> and then use the join command to
> let the filename (i.e. $11) as key
> and then compare the 2 filesize values (i.e. $7)
>
> This work for 99.9%
> except when the filename contain SPACE or SPACES.
>
> My question is:
> Can the find -ls
> command use TAB or other non-space character
> as the field separator ?
>
> If not, any idea to solve this problem ?


find MyDirectory -type f -printf "%p %s\n"



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
Reply With Quote
  #4  
Old 09-01-2008, 01:58 AM
Default Re: find -ls field separator

On 8月28日, 下午6時25分, pk wrote:
> On Thursday 28 August 2008 12:06, Alvin SIU wrote:
>
>
>
>
>
> > Hi all,

>
> > I am using AIX 5.2 and 5.3
> > and have to do data migration from old machine to new machine.

>
> > After migration, I have to do verification.

>
> > There is a very quick and dirty verification
> > is to ensure the filesize is the same after the migration.

>
> > The method is very simple:
> > find MyDirectory -type f -ls | awk '{print $11, $7}'

>
> > To produce a report in both the old and new machine
> > and then use the join command to
> > let the filename (i.e. $11) as key
> > and then compare the 2 filesize values (i.e. $7)

>
> > This work for 99.9%
> > except when the filename contain SPACE or SPACES.

>
> > My question is:
> > Can the find -ls
> > command use TAB or other non-space character
> > as the field separator ?

>
> I don't know, but you can of course change your awk program.
> For example:
>
> find MyDirectory -type f -ls | \
> awk '{s=$7;sub(/^([^[:space:]]*[[:space:]]*){10}/,"");print $0,s}'
>
> --
> 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.- 隱藏被引用文字 -
>
> - 顯示被引用文字 -


Thanks pk,
It works.
Alvin SIU
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 11:13 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.