Skip to content

Tag: sh

How echo grave accent symbol in bash

(_ is input, i think) Answer Escape the grave accent. It’s special to the shell and is one way (the archaic one) to do command substitution. As noted by @dave_thompson_085 an alternative is to use single quotes in lieu of the double quotes you used, or to specify the hexadecimal representation of the grace accent, by doing echo “x60”. You

aws cli describe cluster error using ‘for loop’

I’m having trouble trying to run a for loop with the aws cli command aws eks describe-cluster. I receive the below error on execution. My scripting is not the best. Any help would be greatly appreciated. Thanks. If I simply run aws eks list-clusters | grep dev-shark it outputs the below: It seems to be the comma (,) that is

How do I copy first 3 lines and last 2 lines of a file, and create new file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question

Split/Slice large JSON using jq

Would like to SLICE a huge json file ~20GB into smaller chunk of data based on array size (10000/50000 etc).. Input: Currently running in a loop to get the desire output by incrementing x/y value, but performance is very slow and takes very 8-20 seconds for a iteration depends on size of the file to complete the split process. Currently

Getting bad substitution error in shell script

I have a variable COUNTRY=”INDIA” and another sets of variables:- INDIA_POPULATION=”5,00,00,000″, CHINA_POPULATION=”6,00,00,000″. In script I am trying to call them using command:- echo ${ ${COUNTRY}_POPULATION } But I am getting bad substitution error. Can someone please tell how to solve it ?? Answer You misplaced a bracket: {$COUNTRY}_POPULATION should be ${COUNTRY}_POPULATION. But even then it would not work as you

Shell script ‘read’ doesnt work with ‘EOF’

This script below is working, I want to read a value from files and used it in syntax. But this script below doesn’t work, it keeps saying : -bash: syntax error near unexpected token `;’ Please help, whats wrong with the 2nd script.. Answer Just close the HEREDOC, like this:

Linux Shell Script – Mounting and Backing Up Files

I’m writing my first shell script. I want to check if a filesystem is mounted. If so, then backup the documents from my main drive to the backup that is mounted. If not, mount the filesystem, then backup the documents. I executed the script, yet all I got was a lot of text. It didn’t perform as I wanted. Did