Presentation is loading. Please wait.

Presentation is loading. Please wait.

Find Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files.

Similar presentations


Presentation on theme: "Find Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files."— Presentation transcript:

1 Find http://find.unixpin.com/

2 Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files whose name (-name) is myfile and displays them (-print) You need to say –print if you want to print out the names of files.

3 Finding Files find. -user root -exec wc {} \; executes wc on all files in cwd owned by user root {} is shorthand for the name of that file. the ; (must be escaped with a \) terminates the action to be taken.

4 Remove – with care find. -name "this*" -exec rm {} \; This will remove all the files matching “this*”, starting in the current directory (.) Be careful with this sort of command!

5 Pass find to my script. find. -name "myfile*" -exec myFileProcessor.sh {} \; I can pass what I want to myFileProcessor.sh echo file is $1 echo "I can do what I want to the file here“ file is./myfile I can do what I want to the file here file is./myfile2 I can do what I want to the file here

6 Arguments to Find Arguments are of 3 kinds options which affect behavior tests which specify which files are to be selected action specify what is to be done to the selected files.

7 Tests Used by Find -empty, file is empty -links n, file has n hard links -inum n, file's inode is n -name pattern, filename matches pattern -perm mode, file permissions are exactly mode -size n, file has size blocks of 512 bytes -type c, file is type c -user name, file owner is name

8 Do not forget this webpage http://find.unixpin.com/ There are lots of other good tutorial “out there” Find is one of the hardest commands to master.

9 Ssh – secure shell Other tools are rlogin, rsh, rcp – but these are not used because of security issues. Ssh is probably the most popular of these tools. A key is sent, so both machines can communicate with encrypted information.

10 Ssh example $ whoami zlizjw1 ssh jrw@cs.nott.ac.uk It is a criminal offence to secure unauthorised access to any program or …… pat$ whoami jrw pat$

11 Example mailx pat$ mailx -s "hi from UK" john.woodward@nottingham.edu.cn how is Ningbo EOT pat$

12 To exit pat$ exit logout Connection to cs.nott.ac.uk closed. [zlizjw1@unnc-cslinux ~]$ whoami zlizjw1 [zlizjw1@unnc-cslinux ~]$

13 Non-interactive We can just send commands ssh –l login remote.machine.name command For example ssh -l jrw cs.nott.ac.uk mkdir SSHDIRJOHN There are lots more to this. This is just the basics.

14 Secure copy (scp) scp SourceFile user@host:directory/TargetFile scp A.TXT jrw@cs.nott.ac.uk:SSHDIRJOHN/A.TXT jrw@cs.nott.ac.uk:SSHDIRJOHN/A.TXT jrw@cs.nott.ac.uk's password: A.TXT 100% 0 0.0KB/s 00:00 pat$ cd SSHDIRJOHN/ pat$ ls A.TXT pat$

15 Gzip, gunzip, Compression gzip is short for GNU zip for the compress program used in early Unix systems, intended for use by the GNU ProjectcompressUnixGNU Project www.gzip.org Compression is very important in computer science.

16 BEFORE ls -l -rwxr--r-- 1 zlizjw1 Domain U 228785 Mar 17 11:05 canonical.pdf -rw-r--r-- 1 zlizjw1 Domain U 4485370 Mar 17 11:05 canonical.ps

17 AFTER gzip $ gzip canonical.p* $ ls -l total 744 -rwxr--r-- 1 zlizjw1 Domain U 201204 Mar 17 11:05 canonical.pdf.gz -rw-r--r-- 1 zlizjw1 Domain U 548712 Mar 17 11:05 canonical.ps.gz

18 AFTER gunzip gunzip canonical.p* ls -l total 4624 -rwxr--r-- 1 zlizjw1 Domain U 228785 Mar 17 11:05 canonical.pdf -rw-r--r-- 1 zlizjw1 Domain U 4485370 Mar 17 11:05 canonical.ps

19 Archive, tar tape archive standardized by POSIX.1-1988 and later POSIX.1-2001.POSIX it is now commonly used to collect many files into one larger file, for distribution or archiving, while preserving file system information such as user and group permissions, dates, and directory structures.distribution archivingfile systemdirectory.

20 http://www.gnu.org/software/tar/ A tar file or compressed tar file is commonly referred to as a tarball

21 Create a tar file tar cvf myTarfile files c for create v for verbose f to specify tarfile For example Tar cvf UST.tar * Will tar everything in your working directory into a file called tar

22 Extract from tar file To extract the contents from a tar file Tar xvf tarfile This extracts the files from the tarfile X is for extract T is to give a table of contents.


Download ppt "Find Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files."

Similar presentations


Ads by Google