bash script to change directory and execute command with arguments - Stack Overflow (https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (Stack Overflow) (/opensearch.xml) (https://stackoverflow.com/questions/8369411/bash-script-to-change-directory-and-execute-command-with-arguments) (https://cdn.sstatic.net/Shared/stacks.css?v=bd2aba62c5a4) (https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=cc49ce762956) (Feed for question 'bash script to change directory and execute command with arguments') (/feeds/question/8369411) (https://cdn.sstatic.net/Shared/Channels/channels.css?v=5981bb1a5bd7) (https://accounts.google.com/gsi/style) (site logo) Join Stack Overflow By clicking “Sign up”, you agree to our (/legal/terms-of-service/public) terms of service and acknowledge you have read our (/legal/privacy-policy) privacy policy . (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) (1) (2.0) Sign up with Google Sign up with GitHub OR (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) (1) () () () () () () Email Password (8+ characters (at least 1 letter & 1 number)) Sign up Already have an account? (/users/login) Log in (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) () Skip to main content (https://stackoverflow.com) Stack Overflow (https://stackoverflow.co/) About Products (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav-bar&utm_content=overflowai) OverflowAI (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams) Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising) Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-ai) OverflowAI GenAI features for Teams (https://stackoverflow.co/api-solutions/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api) OverflowAPI Train & fine-tune LLMs (https://stackoverflow.co/labs/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=labs) Labs The future of collective knowledge sharing (https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) About the company (https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog) Visit the blog (Search…) () Loading… (https://stackoverflow.com) current community (https://stackoverflow.com) (Stack Overflow) Stack Overflow (https://stackoverflow.com/help) help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) chat (https://meta.stackoverflow.com) (Meta Stack Overflow) Meta Stack Overflow your communities (https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f8369411%2fbash-script-to-change-directory-and-execute-command-with-arguments) Sign up or (https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f8369411%2fbash-script-to-change-directory-and-execute-command-with-arguments) log in to customize your list. (https://stackexchange.com/sites) more stack exchange communities (https://stackoverflow.blog) company blog (Click to show search) (https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f8369411%2fbash-script-to-change-directory-and-execute-command-with-arguments) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f8369411%2fbash-script-to-change-directory-and-execute-command-with-arguments) Sign up Ask questions and share your thoughts on the future of Stack Overflow. Join our first live community AMA this Wednesday, February 26th, at 3 PM ET. (https://meta.stackexchange.com/questions/406399/join-us-for-our-first-community-wide-ama-ask-me-anything-with-stack-overflow-s?utm_medium=ppc&utm_source=stackoverflow-community&utm_campaign=community-ama&utm_content=announcement-banner2) Learn more (dismiss) Let's set up your homepage Select a few topics you're interested in: python javascript c# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: (Search) javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json python-3.x .net ruby-on-rails sql-server swift django angular objective-c excel pandas angularjs regex typescript ruby linux ajax iphone vba xml laravel spring asp.net-mvc database wordpress string flutter postgresql mongodb wpf windows amazon-web-services xcode bash git oracle-database spring-boot dataframe azure firebase list multithreading docker vb.net react-native eclipse algorithm powershell macos visual-studio numpy image forms scala function vue.js performance twitter-bootstrap selenium winforms kotlin loops express dart hibernate sqlite matlab python-2.7 shell rest apache entity-framework android-studio csv api maven linq qt dictionary unit-testing facebook asp.net-core tensorflow apache-spark file swing class unity-game-engine sorting date authentication go symfony opencv t-sql matplotlib .htaccess google-chrome for-loop datetime codeigniter http perl validation sockets google-maps object uitableview xaml oop if-statement visual-studio-code cordova ubuntu web-services email android-layout github elasticsearch spring-mvc kubernetes selenium-webdriver ms-access user-interface parsing ggplot2 pointers machine-learning google-sheets c++11 security flask google-apps-script ruby-on-rails-3 nginx templates variables exception sql-server-2008 gradle debugging tkinter listview delphi jpa asynchronous pdf web-scraping haskell jsp ssl amazon-s3 google-cloud-platform jenkins testing xamarin wcf npm batch-file generics ionic-framework network-programming unix recursion google-app-engine mongoose visual-studio-2010 .net-core android-fragments assembly animation math next.js session svg hadoop intellij-idea curl django-models join laravel-5 winapi rust url heroku http-redirect tomcat google-cloud-firestore inheritance webpack keras image-processing asp.net-mvc-4 gcc web logging dom swiftui matrix pyspark actionscript-3 button post optimization firebase-realtime-database jquery-ui cocoa iis xpath d3.js firefox javafx internet-explorer xslt caching select asp.net-mvc-3 opengl events asp.net-web-api plot dplyr magento encryption search stored-procedures amazon-ec2 ruby-on-rails-4 memory audio canvas multidimensional-array jsf random vector cookies redux facebook-graph-api input flash xamarin.forms indexing arraylist ipad cocoa-touch data-structures video apache-kafka model-view-controller serialization jdbc woocommerce routes razor azure-devops awk servlets mod-rewrite beautifulsoup docker-compose iframe filter excel-formula aws-lambda design-patterns text django-rest-framework visual-c++ cakephp mobile android-intent react-hooks struct methods groovy mvvm ssh lambda checkbox google-chrome-extension ecmascript-6 time grails installation sharepoint cmake shiny spring-security jakarta-ee android-recyclerview plsql core-data types meteor android-activity sed bootstrap-4 websocket activerecord graph replace scikit-learn file-upload group-by vim junit deep-learning boost import sass memory-management error-handling async-await eloquent dynamic soap silverlight dependency-injection charts layout apache-spark-sql deployment browser gridview svn while-loop google-bigquery vuejs2 ffmpeg dll highcharts view foreach plugins makefile c#-4.0 redis reporting-services jupyter-notebook server merge https unicode reflection google-maps-api-3 twitter oauth-2.0 extjs pytorch axios terminal pip split mysqli cmd django-views encoding automation netbeans database-design collections hash build data-binding ember.js tcp sqlalchemy pdo apache-flex concurrency command-line entity-framework-core spring-data-jpa printing java-8 react-redux jestjs service html-table neo4j ansible lua parameters material-ui module visual-studio-2012 enums promise flexbox outlook webview firebase-authentication web-applications uwp jquery-mobile utf-8 datatable python-requests parallel-processing drop-down-menu colors scroll hive tfs scipy count syntax ms-word twitter-bootstrap-3 ssis google-analytics three.js fonts powerbi constructor graphql rxjs file-io paypal discord cassandra socket.io graphics compiler-errors gwt react-router nlp solr backbone.js url-rewriting datatables memory-leaks oauth datagridview terraform drupal oracle11g zend-framework neural-network knockout.js triggers django-forms interface google-api angular-material casting jmeter linked-list proxy path timer django-templates arduino orm directory parse-platform visual-studio-2015 windows-phone-7 cron push-notification conditional-statements primefaces functional-programming pagination model jar xamarin.android hyperlink uiview visual-studio-2013 gitlab vbscript google-cloud-functions azure-active-directory jwt download swift3 sql-server-2005 process configuration rspec properties pygame combobox callback windows-phone-8 safari linux-kernel permissions scrapy raspberry-pi scripting emacs clojure scope io x86 compilation mongodb-query responsive-design nhibernate angularjs-directive request expo bluetooth 3d dns azure-functions binding reference discord.js architecture playframework pyqt version-control doctrine-orm package pycharm get sql-server-2012 rubygems f# autocomplete datepicker openssl kendo-ui tree jackson controller yii nested grep xamarin.ios static dockerfile statistics transactions null datagrid active-directory uiviewcontroller phpmyadmin webforms discord.py notifications computer-vision sas duplicates mocking youtube nullpointerexception yaml menu sum bitmap electron asp.net-mvc-5 visual-studio-2008 time-series yii2 jsf-2 css-selectors android-listview stl blazor floating-point cryptography ant stream hashmap character-encoding msbuild sdk asp.net-core-mvc google-drive-api selenium-chromedriver jboss joomla navigation cors devise anaconda frontend background camera pyqt5 multiprocessing binary cuda linq-to-sql iterator mariadb onclick ios7 plotly rabbitmq android-asynctask android-jetpack-compose microsoft-graph-api tabs insert laravel-4 amazon-dynamodb uicollectionview environment-variables linker console xsd coldfusion upload continuous-integration ftp textview opengl-es operating-system mockito vuejs3 localization xml-parsing macros formatting json.net kivy type-conversion data.table timestamp calendar integer segmentation-fault android-ndk drag-and-drop prolog char crash jasmine automated-tests dependencies geometry android-gradle-plugin itext firebase-cloud-messaging header sprite-kit mfc fortran attributes nosql nuxt.js format nestjs azure-pipelines odoo jquery-plugins db2 leaflet jenkins-pipeline event-handling postman flutter-layout annotations julia keyboard textbox arm visual-studio-2017 gulp libgdx stripe-payments xampp synchronization crystal-reports azure-web-app-service timezone dom-events android-emulator swagger uikit wso2 sequelize.js aggregation-framework namespaces uiscrollview jvm chart.js google-sheets-formula com subprocess geolocation centos webdriver html5-canvas widget dialog garbage-collection numbers snowflake-cloud-data-platform concatenation sql-update qml windows-10 set mapreduce tuples smtp ionic2 java-stream rotation modal-dialog android-edittext spring-data http-headers nuget doctrine radio-button grid sonarqube lucene xmlhttprequest internationalization listbox components initialization switch-statement google-play apache-camel boolean serial-port ldap ios5 youtube-api return gdb latex pivot eclipse-plugin frameworks tags containers dataset github-actions asp-classic foreign-keys subquery label copy uinavigationcontroller google-cloud-storage c++17 delegates struts2 migration base64 protractor queue sql-server-2008-r2 find uibutton embedded arguments composer-php append jaxb zip stack cucumber autolayout ide entity-framework-6 popup iteration windows-7 airflow r-markdown ssl-certificate vb6 gmail hover jqgrid tailwind-css g++ udp Next You’ll be prompted to create an account to view your personalized homepage. (/) Home (/questions) Questions (/tags) Tags (/users) Users (https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) Companies Labs (/jobs?source=so-left-nav) Jobs (/beta/discussions) Discussions Collectives Communities for your favorite technologies. (/collectives-all) Explore all Collectives Teams () Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Try Teams for free (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Explore Teams Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact) Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. (/collectives) Learn more about Collectives Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. (https://stackoverflow.co/teams/) Learn more about Teams Get early access and see previews of new features. (https://stackoverflow.co/labs/) Learn more about Labs (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (/questions/8369411/bash-script-to-change-directory-and-execute-command-with-arguments) bash script to change directory and execute command with arguments (/questions/ask) Ask Question (2011-12-03 17:16:27Z) Asked 13 years, 2 months ago Modified (?lastactivity) (2015-04-28 06:43:15Z) 9 years, 10 months ago (Viewed 49,025 times) Viewed 49k times This question shows research effort; it is useful and clear (69:3:31e,16:54025fdc38b63837,10:1740472816,16:ba0a466cea192fba,7:8369411,13d172d0aafee450eee0058da87a5d7c0954a8793250367d3c1b195c7ff8fb05) 12 (This question does not show any research effort; it is unclear or not useful) (69:3:31e,16:f7439e933f5c221f,10:1740472816,16:ec5d37544159ea6c,7:8369411,2b5ab779989dcdeb4c6f5858735d0a57b31b616fdfd7780f28b543255c08ce59) Save this question. (/posts/8369411/timeline) Show activity on this post. I am trying to do the following task: write a shell script called changedir which takes a directory name, a command name and (optionally) some additional arguments. The script will then change into the directory indicated, and executes the command indicated with the arguments provided. Here an example: $ sh changedir /etc ls -al This should change into the /etc directory and run the command ls -al . So far I have: #!/bin/sh directory=$1 ; shift command =$1 ; shift args=$1 ; shift cd $directory $command If I run the above like sh changedir /etc ls it changes and lists the directory. But if I add arguments to the ls it does not work. What do I need to do to correct it? (/questions/tagged/bash) (show questions tagged 'bash') bash (/q/8369411) (Short permalink to this question) Share Share a link to this question Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/8369411/edit) () Improve this question Follow (69:3:31e,16:8e32e0bd582f6875,10:1740472816,16:f28d18b197b3e638,7:8369411,4e122fb786b0ca47e44e9689bb067b29032ad9dba82df026a3b779a4a375d257) Follow this question to receive notifications (/posts/8369411/revisions) (show all edits to this post) edited (2011-12-03 18:58:23Z) Dec 3, 2011 at 18:58 (/users/360899/lesmana) (Lesmana's user avatar) (/users/360899/lesmana) Lesmana (reputation score 27,063) 27.1k (12 gold badges) 12 12 gold badges (83 silver badges) 83 83 silver badges (87 bronze badges) 87 87 bronze badges asked (2011-12-03 17:16:27Z) Dec 3, 2011 at 17:16 (/users/1069751/frodo) (frodo's user avatar) (/users/1069751/frodo) frodo frodo (reputation score) 1,063 (6 gold badges) 6 6 gold badges (17 silver badges) 17 17 silver badges (33 bronze badges) 33 33 bronze badges (Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.) Add a comment | (Expand to show all comments on this post) 2 Answers 2 Sorted by: (/questions/8369411/bash-script-to-change-directory-and-execute-command-with-arguments?answertab=scoredesc#tab-top) Reset to default (scoredesc) Highest score (default) (trending) Trending (recent votes count more) (modifieddesc) Date modified (newest first) (createdasc) Date created (oldest first) This answer is useful (69:3:31e,16:76a778d43948df75,10:1740472816,16:717169c7c03b6b70,7:8369446,1b13f2eca6f3641ca92b39de59035d2d4af3e643e965e2e427b10d651d440d67) 20 (This answer is not useful) (69:3:31e,16:69a695fbf4ce9407,10:1740472816,16:b0d1f7f3a661bd25,7:8369446,686453901f548f6e0b633406e61885a4b5d4e584d02875033f1d758f1c6c7536) Save this answer. (Loading when this answer was accepted…) (/posts/8369446/timeline) Show activity on this post. You seemed to be ignoring the remainder of the arguments to your command. If I understand correctly you need to do something like this: #!/bin/sh cd "$1 " # change to directory specified by arg 1 shift # drop arg 1 cmd="$1 " # grab command from next argument shift # drop next argument "$cmd " "$@ " # expand remaining arguments, retaining original word separations A simpler and safer variant would be: #!/bin/sh cd "$1 " && shift && "$@ " (/a/8369446) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/8369446/edit) () Improve this answer Follow (69:3:31e,16:66843347c0aaf1aa,10:1740472816,16:e22d011a082c1faf,7:8369446,40876bd55e2c4b6854e72469afa3ef8def9c898137feec61223b44dcd31c1b1b) Follow this answer to receive notifications (/posts/8369446/revisions) (show all edits to this post) edited (2015-04-28 06:43:15Z) Apr 28, 2015 at 6:43 answered (2011-12-03 17:20:07Z) Dec 3, 2011 at 17:20 (/users/19563/cb-bailey) (CB Bailey's user avatar) (/users/19563/cb-bailey) CB Bailey CB Bailey (reputation score 792,557) 793k (107 gold badges) 107 107 gold badges (644 silver badges) 644 644 silver badges (665 bronze badges) 665 665 bronze badges 2 Thank you Charles ....am I right in making the last line above to be "$cmd" "$@" to make the "arguments" optional to the command i.e. if I run "./changedir /etc/ ls" it will work ok and also " ./indir /etc/ ls -al" will also work ok – (/users/1069751/frodo) (1,063 reputation) frodo Commented (2011-12-03 17:41:32Z, License: CC BY-SA 3.0) Dec 3, 2011 at 17:41 @frodo: Yes, you are right. "$@" is better because it preserves arguments as they are passed. It's what I meant but not what I wrote! – (/users/19563/cb-bailey) (792,557 reputation) CB Bailey Commented (2011-12-03 18:24:38Z, License: CC BY-SA 3.0) Dec 3, 2011 at 18:24 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful (69:3:31e,16:483248671bc47035,10:1740472816,16:44bd078c654f8e61,7:8369583,2ba962f8cef9efcb2b2908327f5d27048ca3e2c6976fee0b3cbf3b039cc3c8a7) -1 (This answer is not useful) (69:3:31e,16:128010b79ccdb790,10:1740472816,16:c10115040a051e23,7:8369583,2b4104b285549aa32cd75ab8cb6b0af6fedb0c14f031acc25cc502a9624c2438) Save this answer. (Loading when this answer was accepted…) (/posts/8369583/timeline) Show activity on this post. Since there can probably be more than a single argument to a command, i would recommend using quotation marks. Something like this: sh changedir.sh /etc "ls -lsah" Your code would be much more readable if you ommited the 'shift': directory=$1 ; command =$2 ; cd $directory $command or simply cd DIRECTORY_HERE; COMMAND_WITH_ARGS_HERE (/a/8369583) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/8369583/edit) () Improve this answer Follow (69:3:31e,16:ae5d0996e92ee511,10:1740472816,16:bfe67542670ad513,7:8369583,97fc1ba91ac5ce45c7e84e6ab75255df03bea871fda8b626a64a4e333509d61e) Follow this answer to receive notifications (/posts/8369583/revisions) (show all edits to this post) edited (2011-12-05 09:25:03Z) Dec 5, 2011 at 9:25 answered (2011-12-03 17:40:10Z) Dec 3, 2011 at 17:40 (/users/1075878/dgasper) (dgasper's user avatar) (/users/1075878/dgasper) dgasper dgasper (reputation score) 212 (2 silver badges) 2 2 silver badges (7 bronze badges) 7 7 bronze badges 2 (number of 'useful comment' votes received) 1 (http://mywiki.wooledge.org/BashFAQ/050) This way lies madness . @Charles Bailey's method handles arguments much more cleanly. – (/users/89817/gordon-davisson) (125,958 reputation) Gordon Davisson Commented (2011-12-03 23:09:37Z, License: CC BY-SA 3.0) Dec 3, 2011 at 23:09 True that handling more complex commands could be cumbersome but for the simple case menioned here it should suffice. It is also much clearer what the directory part and the command parts are, since the arguments really belong to the command and have no meaning on their own. – (/users/1075878/dgasper) (212 reputation) dgasper Commented (2011-12-05 09:20:55Z, License: CC BY-SA 3.0) Dec 5, 2011 at 9:20 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) (8369411) (false) () Your Answer (False) Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. (/help/gen-ai-policy) Learn more (true) Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question . Provide details and share your research! But avoid … Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our (/help/how-to-answer) tips on writing great answers . Draft saved Draft discarded (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) Sign up or (/users/login?ssrc=question_page&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f8369411%2fbash-script-to-change-directory-and-execute-command-with-arguments%23new-answer) log in Sign up using Google Sign up using Email and Password (false) (false) Submit Post as a guest Name () () Email Required, but never shown () () Post as a guest Name () () Email Required, but never shown () () Post Your Answer Discard By clicking “Post Your Answer”, you agree to our (https://stackoverflow.com/legal/terms-of-service/public) terms of service and acknowledge you have read our (https://stackoverflow.com/legal/privacy-policy) privacy policy .(1) Not the answer you're looking for? Browse other questions tagged (/questions/tagged/bash) (show questions tagged 'bash') bash or (/questions/ask) ask your own question . The Overflow Blog (https://stackoverflow.blog/2025/02/21/one-quality-every-engineering-manager-should-have-empathy/?cb=1) One quality every engineering manager should have? Empathy. (https://stackoverflow.blog/2025/02/24/writing-tests-with-ai-but-not-llms/?cb=1) Writing tests with AI, but not LLMs Featured on Meta (Meta Stack Exchange) (https://meta.stackexchange.com/questions/406399/join-us-for-our-first-community-wide-ama-ask-me-anything-with-stack-overflow-s?cb=1) (Join us for our first community-wide AMA (Ask Me Anything) with Stack Overflow’s CEO (and a few others) on February 26, 2025) Join us for our first community-wide AMA (Ask Me Anything) with Stack... (Meta Stack Exchange) (https://meta.stackexchange.com/questions/406575/bigbird-and-frog-have-joined-us-as-community-managers?cb=1) bigbird and Frog have joined us as Community Managers (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/433034/stacks-editor-development-and-testing?cb=1) Stacks Editor development and testing (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/432989/is-it-better-to-redirect-users-who-attempt-to-perform-actions-they-cant-yet-tak?cb=1) (Is it better to redirect users who attempt to perform actions they can't yet take?) Is it better to redirect users who attempt to perform actions they can't yet... (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned?cb=1) Policy: Generative AI (e.g., ChatGPT) is banned Related (https://stackoverflow.com/q/2576297?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/2576297/change-shell-directory-from-a-script?rq=3) change shell directory from a script? (https://stackoverflow.com/q/8275068?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/8275068/change-directory-in-a-shell-script-and-using-expr?rq=3) Change directory in a shell script, and using expr (https://stackoverflow.com/q/11002580?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/11002580/changing-directory-within-a-bash-script?rq=3) Changing directory within a bash script (https://stackoverflow.com/q/19179742?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/19179742/how-to-change-directory-through-a-script-file?rq=3) How to change directory through a script file (https://stackoverflow.com/q/19281328?rq=3) (Question score (upvotes - downvotes)) 34 (https://stackoverflow.com/questions/19281328/shell-script-change-directory-with-variable?rq=3) Shell script change directory with variable (https://stackoverflow.com/q/20967267?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/20967267/shell-script-to-change-to-another-directory-using-variables-in-the-script?rq=3) Shell Script to change to another directory using variables in the script (https://stackoverflow.com/q/24252680?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/24252680/change-directories-in-shell-scripts-with-string-variables?rq=3) Change directories in shell scripts with string variables (https://stackoverflow.com/q/29884519?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/29884519/change-directory-to-argument-if-given-bash-scripting?rq=3) Change Directory to Argument (if given) - Bash Scripting (https://stackoverflow.com/q/64940921?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/64940921/bash-script-to-change-directory-from-user-input?rq=3) Bash script to change directory from user input (https://stackoverflow.com/q/65509921?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/65509921/how-to-change-current-directory-via-shell-script-and-execute-command-there?rq=3) How to change current directory via shell script and execute command there? (https://stackexchange.com/questions?tab=hot) Hot Network Questions (Academia Stack Exchange) (https://academia.stackexchange.com/questions/216989/bsc-thesis-with-no-significant-results) BSc: Thesis with no significant results (Academia Stack Exchange) (https://academia.stackexchange.com/questions/216967/when-submitting-to-a-journal-should-i-explain-how-i-handled-comments-from-submi) When submitting to a journal, should I explain how I handled comments from submissions to different journals? (Law Stack Exchange) (https://law.stackexchange.com/questions/107534/can-bags-that-arent-suspicious-be-searched-or-seized-at-an-international-airpor) Can bags that aren't suspicious be searched or seized at an international airport? (Biblical Hermeneutics Stack Exchange) (https://hermeneutics.stackexchange.com/questions/101772/how-do-men-nullify-or-make-gods-word-of-none-effect-when-jesus-has-said-his-wor) How do men nullify or make God's word of none effect when Jesus has said his words will never pass away? (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5039023/cubic-matrix-equation) Cubic matrix equation (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5039199/riesz-isomorphism-why-not-like-this) Riesz isomorphism: Why not like this? (MathOverflow) (https://mathoverflow.net/questions/488393/homology-of-a-group-over-the-inverse-limit-of-coefficient-modules) Homology of a group over the inverse limit of coefficient modules (Worldbuilding Stack Exchange) (https://worldbuilding.stackexchange.com/questions/264876/is-there-a-soil-type-unsuited-for-grain-but-suitable-for-orchards-that-can-appea) Is there a soil type unsuited for grain but suitable for orchards that can appear alongside a river? (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/130694/alphabet-hides-number) Alphabet hides number! (The Workplace Stack Exchange) (https://workplace.stackexchange.com/questions/200413/how-to-encourage-communication-by-email-or-im) How to encourage communication by email or IM? (Bicycles Stack Exchange) (https://bicycles.stackexchange.com/questions/96263/can-i-save-these-wheels) Can I save these wheels? (Software Engineering Stack Exchange) (https://softwareengineering.stackexchange.com/questions/456698/structuring-multiple-teams-within-an-organisation) Structuring multiple teams within an organisation (Cross Validated) (https://stats.stackexchange.com/questions/661794/clustered-standard-error-intuitions) Clustered standard error intuitions (Worldbuilding Stack Exchange) (https://worldbuilding.stackexchange.com/questions/264887/could-tiny-people-find-honest-work) Could tiny people find honest work? (Role-playing Games Stack Exchange) (https://rpg.stackexchange.com/questions/214818/is-the-movable-function-of-the-grappled-condition-subject-to-the-grapplers-stre) Is the Movable function of the Grappled Condition subject to the Grappler's strength score? (Latin Language Stack Exchange) (https://latin.stackexchange.com/questions/24479/usurpare-use-or-usurp-a-question-about-perfect-vs-imperfect-tense) Usurpare: use or usurp? A question about perfect vs. imperfect tense (Proof Assistants Stack Exchange) (https://proofassistants.stackexchange.com/questions/4767/redundant-assumptions-in-mltt-rules) Redundant assumptions in MLTT rules? (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5039198/linear-combinations-of-minor-determinants) Linear combinations of minor determinants (Stack Overflow) (https://stackoverflow.com/questions/79461907/how-can-i-transparently-process-stdvector-of-t-and-stdvector-of-stdshared) How can I transparently process std::vector of T and std::vector of std::shared_ptr in a template? (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/questions/791565/add-columns-from-variable-number-of-files-to-base-file) Add columns from variable number of files to base file (Science Fiction & Fantasy Stack Exchange) (https://scifi.stackexchange.com/questions/295103/what-was-the-first-sff-movie-to-influence-later-books-in-the-same-franchise) What was the first SFF movie to influence later books in the same franchise? (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/737819/let-qed-symbol-be-right-after-the-text-of-the-proof) Let qed symbol be right after the text of the proof (Chemistry Stack Exchange) (https://chemistry.stackexchange.com/questions/187558/why-do-some-liquid-pharmaceutical-suspensions-require-shaking-while-others-dont) Why do some liquid pharmaceutical suspensions require shaking while others don't? (Space Exploration Stack Exchange) (https://space.stackexchange.com/questions/67945/could-india-possibly-deflect-the-asteroid-2024-yr4) Could India possibly deflect the asteroid 2024 YR4? (/feeds/question/8369411) (Feed of this question and its answers) Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. (https://stackoverflow.com/feeds/question/8369411) () lang-bash (https://stackoverflow.com) (https://stackoverflow.com) Stack Overflow (/questions) Questions (/help) Help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) Chat (https://stackoverflow.co/) Products (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams) Teams (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising) Advertising (https://stackoverflow.co/advertising/employer-branding/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=talent) Talent (https://stackoverflow.co/) Company (https://stackoverflow.co/) About (https://stackoverflow.co/company/press/) Press (https://stackoverflow.co/company/work-here/) Work Here (https://stackoverflow.com/legal) Legal (https://stackoverflow.com/legal/privacy-policy) Privacy Policy (https://stackoverflow.com/legal/terms-of-service/public) Terms of Service (/contact) Contact Us Cookie Settings (https://stackoverflow.com/legal/cookie-policy) Cookie Policy (https://stackexchange.com) Stack Exchange Network (https://stackexchange.com/sites#technology) Technology (https://stackexchange.com/sites#culturerecreation) Culture & recreation (https://stackexchange.com/sites#lifearts) Life & arts (https://stackexchange.com/sites#science) Science (https://stackexchange.com/sites#professional) Professional (https://stackexchange.com/sites#business) Business (https://api.stackexchange.com/) API (https://data.stackexchange.com/) Data (https://stackoverflow.blog?blb=1) Blog (https://www.facebook.com/officialstackoverflow/) Facebook (https://twitter.com/stackoverflow) Twitter (https://linkedin.com/company/stack-overflow) LinkedIn (https://www.instagram.com/thestackoverflow) Instagram Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under (https://stackoverflow.com/help/licensing) CC BY-SA . rev 2025.2.24.23038