{"id":1890,"date":"2023-03-16T10:55:51","date_gmt":"2023-03-16T15:55:51","guid":{"rendered":"https:\/\/blog.ls-al.com\/?p=1890"},"modified":"2023-03-19T08:18:15","modified_gmt":"2023-03-19T13:18:15","slug":"bash-alias-inside-a-script","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/bash-alias-inside-a-script\/","title":{"rendered":"Bash alias inside a script"},"content":{"rendered":"
If you need to use an alias inside a script you need this:<\/p>\n
shopt -s expand_aliases\nsource ~\/.bash_aliases<\/code><\/pre>\nI recently started using the docker OCI client instead of trying to install it local. For some reason it is just not working. So now I use the docker image but as you can see you dont want to be using this command everytime.<\/p>\n
docker run --rm -it -v \"$HOME\/.oci:\/oracle\/.oci\" oci<\/code><\/pre>\nSo an alias is helpful but as mentioned wont just work in you script. Example how I use the command in a script and this works. My alias is ocicli.<\/p>\n
CREATED_APPLY_JOB_ID=$(ocicli resource-manager job create-apply-job --stack-id $CREATED_STACK_ID --execution-plan-strategy FROM_PLAN_JOB_ID --execution-plan-job-id \"$CREATED_PLAN_JOB_ID\" --wait-for-state SUCCEEDED --query 'data.id' --raw-output)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"If you need to use an alias inside a script you need this: shopt -s expand_aliases source ~\/.bash_aliases I recently<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,87],"tags":[],"class_list":["post-1890","post","type-post","status-publish","format-standard","hentry","category-bash","category-oci"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1890"}],"version-history":[{"count":2,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1890\/revisions"}],"predecessor-version":[{"id":1893,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1890\/revisions\/1893"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}