Operating System - HP-UX
1828867 Members
2598 Online
109985 Solutions
New Discussion

Some Unix Important Commands Please ...

 
Shahbaz_1
Regular Advisor

Some Unix Important Commands Please ...

Hi,
Can I get some commands like,
-- mv or cp files of or to and same condition with rm (delete).
and can I apply same thing to "rcp"?

-- ls command sorting on "file size", "owner".

Please ....

Thanks & Regards
Syed

Let's share the great thing "THE KNOWLEDGE"
3 REPLIES 3
Deepak Extross
Honored Contributor

Re: Some Unix Important Commands Please ...

T G Manikandan
Honored Contributor

Re: Some Unix Important Commands Please ...

S.K. Chan
Honored Contributor

Re: Some Unix Important Commands Please ...

Lets start from the easiest to the hardest .. some simple example is best shown here .. check the man pages for details of the options I used ..
1) Sort file in ls output by file size
# ls -l | sort -k 5,5
2) Sort file in ls output by owner
# ls -l | sort -k 3,3
3) Copy all files dated "Apr 25" (year not taken into account here) to /tmp.
# for file in `ls -l|grep "Apr 25"|awk '{print $9}'
>do
>cp $file /tmp
>done
4) Remove all files dated between Apr25 2002 and Apr29 2002.
# touch 04240101 /tmp/refa
# touch 04290101 /tmp/refb
# find . \( -newer refa -a ! -newer refb \) -exec rm {} \;
5) Copy all files dated between Apr25 2002 and Apr29 2002 to remote machine called "mars" and put them in /tmp. Use the same date reference as in 4.
# (find . -xdev \( -newer refa -a ! -newer refb \) | cpio -coax) | remsh mars "cd /tmp ; cpio -icdmuxla"

Make sure test them thoroughly ..