{"id":24,"date":"2011-04-18T08:22:00","date_gmt":"2011-04-18T08:22:00","guid":{"rendered":"http:\/\/mattdturner.com\/wordpress\/?p=24"},"modified":"2011-04-26T14:16:27","modified_gmt":"2011-04-26T20:16:27","slug":"some-useful-cshrc-functions","status":"publish","type":"post","link":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/","title":{"rendered":"Some Useful .cshrc Functions"},"content":{"rendered":"<p><span style=\"line-height: 24px;\"><span style=\"font-family: inherit;\">If you use the command line a lot, there are numerous common commands that can be automated to save time.<\/span><\/span><\/p>\n<p>Like what? Well, how about swapping the names of 2 files; or maybe unarchiving any filetype.<\/p>\n<p>People who use bash are lucky, bash allows you to actually create functions in the .bashrc file. Those of use who use c-shell, however, have to deal with aliasing.<\/p>\n<p>Below are a few \u201cfunctions\u201d that i have in my .cshrc file which save me a lot of time.<\/p>\n<h3 style=\"margin-bottom: -20px;\"><span style=\"font-family: inherit;\">Swap 2 files<\/span><\/h3>\n<p><span style=\"font-family: inherit;\"><br \/>\n<code>alias swap 'mv !:1 tmp.1 | mv !:2 !:1 | mv tmp.1 !:2'<\/code><br \/>\nUse:\u00a0<code>mturner@<strong>prospero: <\/strong>swap file1.f file2.f<\/code><br \/>\nResult: The filenames have been swapped for these 2 files<\/span><\/p>\n<h3 style=\"margin-bottom: -20px;\"><span style=\"font-family: inherit;\">Move and go<\/span><\/h3>\n<p><span style=\"font-family: inherit;\"><br \/>\n<code>alias mvg 'mv !:1 !:2 &amp;&amp; cd !:2'<\/code><br \/>\nUse:\u00a0<code>mturner@<strong>prospero: <\/strong>mvg file1.f ~\/Desktop<\/code><br \/>\nResult: file1.f will be moved to the specified directory, and you are automatically cd\u2019ed to the specified directory<br \/>\n<\/span><!--more--><\/p>\n<h3 style=\"margin-bottom: -20px;\"><span style=\"font-family: inherit;\">Copy and go<\/span><\/h3>\n<p><span style=\"font-family: inherit;\"><br \/>\n<code>alias cpg 'cp !:1 !:2 &amp;&amp; cd !:2'<\/code><br \/>\nUse:\u00a0<code>mturner@<strong>prospero: <\/strong>cpg file1.f ~\/Desktop<\/code><br \/>\nResult: Same as \u201cmove and go\u201d but the file is copied, instead of moved<\/span><\/p>\n<h3 style=\"margin-bottom: -20px;\"><span style=\"font-family: inherit;\">Find a file<\/span><\/h3>\n<p><span style=\"font-family: inherit;\"><br \/>\n<code>alias findit 'find . -iname \"!:1\" -print'<\/code><br \/>\nUse:\u00a0<code>mturner@<strong>prospero:<\/strong> findit file1.f<\/code><br \/>\nResult: The alias will search the current folder, as well as all sub-directories, for a file named file.f. The search is NOT case-sensitive.<\/span><\/p>\n<h3 style=\"margin-bottom: -20px;\">Extract any common archive format<\/h3>\n<p><code>alias extract 'eval \"if (!* =~ *.tar.gz) then \\<br \/>\ntar xvzf !* \\<br \/>\nelse \\<br \/>\nif(!* =~ *.tar.bz2) tar xvjf !* \\<br \/>\nif(!* =~ *.bz2) bunzip !* \\<br \/>\nif(!* =~ *.rar) unrar x !* \\<br \/>\nif(!* =~ *.gz) gunzip !* \\<br \/>\nif(!* =~ *.tar) tar xvf !* \\<br \/>\nif(!* =~ *.tbz2) tar xvjf !* \\<br \/>\nif(!* =~ *.tgz) tar xvzf !* \\<br \/>\nif(!* =~ *.zip) unzip !* \\<br \/>\nif(!* =~ *.Z) uncompress !* \\<br \/>\nif(!* =~ *.7z) 7z x !* \\<br \/>\nendif\"'<\/code><\/p>\n<p>Use:\u00a0<code>mturner@<strong>prospero:<\/strong> extract archive1.tar.gz<\/code><br \/>\nResult: This alias will determine the compression technique used to create an archive, and then issue the corresponding command to uncompress the archive. \u00a0 \u00a0\u00a0<span style=\"color: #222222; line-height: 16px;\"><span style=\"font-family: inherit; font-size: xx-small;\">UKUVCTS75QWV<\/span><\/span><\/p>\n<div class=\"zemanta-pixie\" style=\"margin-top: 10px; height: 15px;\"><a class=\"zemanta-pixie-a\" title=\"Enhanced by Zemanta\" href=\"http:\/\/www.zemanta.com\/\"><img decoding=\"async\" class=\"zemanta-pixie-img\" style=\"border: none; float: right;\" src=\"http:\/\/img.zemanta.com\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed\" alt=\"Enhanced by Zemanta\" \/><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you use the command line a lot, there are numerous common commands that can be automated to save time. Like what? Well, how about swapping the names of 2 files; or maybe unarchiving any filetype. People who use bash are lucky, bash allows you to actually create functions in the .bashrc file. Those of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,11,20],"tags":[35,63,58,59,62,61,60,57],"class_list":["post-24","post","type-post","status-publish","format-standard","hentry","category-command-line","category-mac","category-scripting","tag-alias","tag-archive-format","tag-bzip2","tag-c-shell","tag-command-line-interface","tag-gzip","tag-tar-file-format","tag-zip","no-thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Some Useful .cshrc Functions - Tech N Comp<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Some Useful .cshrc Functions - Tech N Comp\" \/>\n<meta property=\"og:description\" content=\"If you use the command line a lot, there are numerous common commands that can be automated to save time. Like what? Well, how about swapping the names of 2 files; or maybe unarchiving any filetype. People who use bash are lucky, bash allows you to actually create functions in the .bashrc file. Those of [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"Tech N Comp\" \/>\n<meta property=\"article:published_time\" content=\"2011-04-18T08:22:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-04-26T20:16:27+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/img.zemanta.com\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed\" \/>\n<meta name=\"author\" content=\"Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/\"},\"author\":{\"name\":\"Admin\",\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/ddfa8276a3c382cc0a217b9cba226f28\"},\"headline\":\"Some Useful .cshrc Functions\",\"datePublished\":\"2011-04-18T08:22:00+00:00\",\"dateModified\":\"2011-04-26T20:16:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/\"},\"wordCount\":200,\"commentCount\":2,\"image\":{\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/img.zemanta.com\\\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed\",\"keywords\":[\"alias\",\"Archive format\",\"Bzip2\",\"C shell\",\"Command-line interface\",\"Gzip\",\"Tar (file format)\",\"zip\"],\"articleSection\":[\"Command Line\",\"Mac\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/\",\"url\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/\",\"name\":\"Some Useful .cshrc Functions - Tech N Comp\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/img.zemanta.com\\\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed\",\"datePublished\":\"2011-04-18T08:22:00+00:00\",\"dateModified\":\"2011-04-26T20:16:27+00:00\",\"author\":{\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/ddfa8276a3c382cc0a217b9cba226f28\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/2011\\\/04\\\/some-useful-cshrc-functions\\\/#primaryimage\",\"url\":\"http:\\\/\\\/img.zemanta.com\\\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed\",\"contentUrl\":\"http:\\\/\\\/img.zemanta.com\\\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed\"},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/#website\",\"url\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/\",\"name\":\"Tech N Comp\",\"description\":\"The one stop shop for everything Technology and Computer Related\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/mattdturner.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/ddfa8276a3c382cc0a217b9cba226f28\",\"name\":\"Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f908010f32d1c51d493f0c45d4ecaadcc12862723680f7d4ff73e7619d611855?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f908010f32d1c51d493f0c45d4ecaadcc12862723680f7d4ff73e7619d611855?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f908010f32d1c51d493f0c45d4ecaadcc12862723680f7d4ff73e7619d611855?s=96&r=g\",\"caption\":\"Admin\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Some Useful .cshrc Functions - Tech N Comp","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/","og_locale":"en_US","og_type":"article","og_title":"Some Useful .cshrc Functions - Tech N Comp","og_description":"If you use the command line a lot, there are numerous common commands that can be automated to save time. Like what? Well, how about swapping the names of 2 files; or maybe unarchiving any filetype. People who use bash are lucky, bash allows you to actually create functions in the .bashrc file. Those of [&hellip;]","og_url":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/","og_site_name":"Tech N Comp","article_published_time":"2011-04-18T08:22:00+00:00","article_modified_time":"2011-04-26T20:16:27+00:00","og_image":[{"url":"http:\/\/img.zemanta.com\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed","type":"","width":"","height":""}],"author":"Admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/#article","isPartOf":{"@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/"},"author":{"name":"Admin","@id":"http:\/\/mattdturner.com\/wordpress\/#\/schema\/person\/ddfa8276a3c382cc0a217b9cba226f28"},"headline":"Some Useful .cshrc Functions","datePublished":"2011-04-18T08:22:00+00:00","dateModified":"2011-04-26T20:16:27+00:00","mainEntityOfPage":{"@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/"},"wordCount":200,"commentCount":2,"image":{"@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/#primaryimage"},"thumbnailUrl":"http:\/\/img.zemanta.com\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed","keywords":["alias","Archive format","Bzip2","C shell","Command-line interface","Gzip","Tar (file format)","zip"],"articleSection":["Command Line","Mac","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/","url":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/","name":"Some Useful .cshrc Functions - Tech N Comp","isPartOf":{"@id":"http:\/\/mattdturner.com\/wordpress\/#website"},"primaryImageOfPage":{"@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/#primaryimage"},"image":{"@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/#primaryimage"},"thumbnailUrl":"http:\/\/img.zemanta.com\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed","datePublished":"2011-04-18T08:22:00+00:00","dateModified":"2011-04-26T20:16:27+00:00","author":{"@id":"http:\/\/mattdturner.com\/wordpress\/#\/schema\/person\/ddfa8276a3c382cc0a217b9cba226f28"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/mattdturner.com\/wordpress\/2011\/04\/some-useful-cshrc-functions\/#primaryimage","url":"http:\/\/img.zemanta.com\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed","contentUrl":"http:\/\/img.zemanta.com\/zemified_e.png?x-id=f33a7d5f-3311-431b-9850-fa14f74e89ed"},{"@type":"WebSite","@id":"http:\/\/mattdturner.com\/wordpress\/#website","url":"http:\/\/mattdturner.com\/wordpress\/","name":"Tech N Comp","description":"The one stop shop for everything Technology and Computer Related","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/mattdturner.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/mattdturner.com\/wordpress\/#\/schema\/person\/ddfa8276a3c382cc0a217b9cba226f28","name":"Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f908010f32d1c51d493f0c45d4ecaadcc12862723680f7d4ff73e7619d611855?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f908010f32d1c51d493f0c45d4ecaadcc12862723680f7d4ff73e7619d611855?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f908010f32d1c51d493f0c45d4ecaadcc12862723680f7d4ff73e7619d611855?s=96&r=g","caption":"Admin"}}]}},"_links":{"self":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts\/24","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/comments?post=24"}],"version-history":[{"count":2,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts\/24\/revisions"}],"predecessor-version":[{"id":69,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/posts\/24\/revisions\/69"}],"wp:attachment":[{"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/media?parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/categories?post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mattdturner.com\/wordpress\/wp-json\/wp\/v2\/tags?post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}