We are using the Bourne-Again Shell. What does this error mean?: syntax error: unexpected end of file Answer The single quoted string starting with is missing the closing single quote. SO’s syntax highlighting shows it, too. Maybe you wanted to backslash the quote? or there are double quotes missing too…
Tag: bash
How to make top run in background ? It needs to run and log the output. Not die or zombie up
I am trying to make a script to log the top output to a file in the background for my embedded system. But as soon as I put it in background, it either exits or zombies up. What is the systems problem with running things in background ? My script I am trying to execute it as and as How
Bash: Parse CSV and edit cell values
I am new to bash scripting I have the following CSV Input Expected Output I need to check Location and Way and convert them to UpperCase – ABC, UP Day needs to be mon – Mon I need to do this for entire CSV. I need to correct the value and write all the fields on to CSV or edit
Bash script: cd No such file or directory when file exists
My bash script is written to go to each subfolder in the current directory: When I run my bash script, I am getting a cd error for a directory that exists: Yet, in terminal command line I can do cd ‘Zelkova serrata’ within the same directory as the script and all is fine. Is it possible the bash s…
Put quotes around string before first forward slash in line by line file read
I am writing a bash script that deletes all the files whose paths are given in delete.txt. delete.txt is thousands of lines long, each line has a path that is structured like this: Where there is a space in the name of the first directory. Currently, my bash script reads each line of delete.txt, saves it to$l…
Error retreiving database name wordpress
I was trying the below code to retrieve database name from wordpress configuration file. But somehow a single inverted comma at the beginning is causing trouble. As given below it shows the output without any special characters but the below error shows an issue. Answer carriage return (r) caused the issue. T…
Running statistics on multiple lines in bash
I have multiple HTTP headers in one giant file, separated with one empty line. I have approximately 10,000,000 of headers separated with an empty line. If I want to discover trends, like header order, I want to do aggregate headers to a one-liner (how I can aggregate lines ending with an empty line and do tha…
Is it possible to reliably nest find -exec commands in linux?
I need to fix permissions on a large number of files from a subset of directories on a large nfs volume. In building up a solution, I started by using find to get a list of the directories I want: The directories all start with a number. I can successfully use this to exec a 2nd find. That find gets
No return after executing passwd command using ssh in script
I have one script which reads hosts IP from /etc/hosts file, do ssh and update the passwords there for the given user. However, the script is closed after setting password for the first host and not able to set password for rest of the hosts. Please find below files- /etc/hosts file- 172.x.x.x host1 172.x.x.x…
Unexpected behaviour of double quotes in bash script
I’ve created a variable which looks like this: If I print it to the terminal, using echo $firstAndLastLines, I get the following output: root bin daemon adm lp Privilege-separated SSH Account used by the trousers package to sandbox the tcsd daemon Norbert Fogarasi But, if I use echo “$firstAndLast…