misc linux bash tidbits
play

Misc. linux/bash tidbits An assortment of linux/bash commands and - PowerPoint PPT Presentation

Misc. linux/bash tidbits An assortment of linux/bash commands and programs that may be handy Most of these have many many options, use the man pages or (probably better/clearer) do a quick online search [caveat: options and behaviour vary


  1. Misc. linux/bash tidbits ● An assortment of linux/bash commands and programs that may be handy ● Most of these have many many options, use the man pages or (probably better/clearer) do a quick online search [caveat: options and behaviour vary somewhat across different flavours of linux]

  2. Finding files and content ● Use the “find” command to search a directory for files with a specific name: “find dirname -name filename -print” (it will show you where in the directory it found the file(s), and wildcards are ok) ● Use the “grep” command to search one or more text files for lines that contain a particular pattern: “grep pattern filename ” ● Use the “diff” command to compare two text files to find differing lines: “diff file1 file2 ”

  3. Zipping/unzipping files ● Often we want to compress a file or group of files, or uncompress one ● To compress use the gzip command: “gzip filename ” (the compressed file will have .gz added to the filename) ● To uncompress use the gunzip command (e.g. gunzip foo.gz)

  4. Archiving files ● To group a directory of files together into a single file (e.g. before compressing) use the tar command: “tar -cvf newarchivename dirname” ● To extract files from an archive, use the command “tar -xvf archivename ” ● Note that tarred files typically use the .tar extension, so if you tar and zip one it will wind up with .tar.gz as extensions (very very common)

  5. Disk utilization ● Often we want to know how much space the files in a directory are using, or which ones are the biggest ● The “du” program lets us specify the directory to analyze, e.g. “du somedir ” lists the sizes of all the files in the directory, whereas “du -s somedir ” just gives total size ● If you’re looking for the “big” files, pipe the results of du into a numeric sort, e.g. “du -s somedir | sort -n”

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend