Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Generic programming in an Interpreted language (as opposed to compiled) executed by a running Shell. Sometimes referred to as "Glue Code" due to the practice of managing the execution and output of one or more compiled binaries and passing said output to another series of commands.

621 questions
0
votes
2 answers

Run a multiline bash script piped from stdin

I'm looking for a simple way to include multi-line scripts inline in documentation to make it transparent what each step does. This works echo "echo 1234" | bash So does this echo 'for N in 1 2 3; do echo $N; done' | bash However, I'd like to use…
Nanzikambe
  • 265
  • 3
  • 8
-1
votes
2 answers

Backup of multiple sites on Ubuntu

I have multiple sites in my /var/www/html/ folder like following:- /var/www/html/site-1 /var/www/html/site-2 /var/www/html/site-3 /var/www/html/site-4 i want to zip each site on my server and to sync on s3 bucket.
Sukhjinder Singh
  • 1,994
  • 2
  • 9
  • 17
-1
votes
1 answer

Make shure that if an error ocurrs the script start again

I have this bash script that runs 2 python scripts in parallel, they bring data from another server via API, they work fine, but sometimes errors ocurrs when connection problems exists, and only fraction of the data is delivered I want to make…
-1
votes
1 answer

what is the right approach to purge /var/spool/abrt/

We want to automate the process of removing old directories from /var/spool/abrt/. We have RHEL machines - version 7.x. The known way is to do the following # systemctl stop abrtd # systemctl stop abrt-oops And we can remove all those directories…
shalom
  • 461
  • 13
  • 29
-1
votes
1 answer

How to call back to the Main Menu

Good Day, I'm new in bash scripting, requesting for your assistance. I'm trying to loop my sub menu to go back to the main menu in glassfish. I'm using if statements. I wish for my script to go back to the Main…
johnmavvv
  • 3
  • 3
-1
votes
2 answers

Trying to execute this shell script but getting this error

Trying to execute this shell script. #!/bin/bash # Proper header for a Bash script. # Cleanup, version 2 # Run as root, of course. # Insert code here to print error message and exit if not root. LOG_DIR=/var/log # Variables are better than…
truthtriumphs
  • 59
  • 1
  • 10
-1
votes
1 answer

How to remove some character from a string in Unix?

I have two string like this a=[2018:09:11-18:37:06:376476] b=[2018:09:11-18:37:06:376446] I want two string like a= 20180911183706376476 b= 20180911183706376446 Can Anyone please help me out?
-1
votes
1 answer

How to pass variable into bash script and use seperate variables with awk?

I have a script that I am using to clear out all lines of a log files older than X days. X can be passed in via command line as well as the log file name, ex usage: ./purge-catalina.sh 3 /opt/tomcat8/logs/catalina.out The script itself looks like…
ninjasense
  • 141
  • 1
  • 6
-1
votes
1 answer

bash + how to avoid specific messages in the log file

when I run the bash script on my Linux machine we get the following errors in my log , note - we set in the script: exec > $log 2>&1 , ( in order to send all standard error/output to $log ) the errors messages: tput: No value for $TERM and no…
jango
  • 59
  • 2
  • 3
  • 12
-1
votes
1 answer

Remove lines from a file in between string

I have query if I can remove few lines from a file in between string. I have an example below: Eg: XML file. < String > Data1 Data2 Data2 < / String > I have a huge XML file in which I want to search a string & delete the data in between the string.…
-1
votes
1 answer

How to collect I/O Bandwidth statistics on ubuntu 14.

I want to write script/service to collect I/O bandwidth consumption on daily basis. I know nload tool which will show total I/O data transfer from the time we executed the command. I want script to generate data for this bandwidth and save in some…
-1
votes
4 answers

Script to delete certain folders based on the time

I need to create a bash script that will remove folders containing backups for specific days. I need to KEEP following: a) files\folders created on FRIDAY @ 23:30 b) files\folders created on the beginning of month (1st of month) c) the most recent…
-1
votes
2 answers

Availability of file for each user directory on bash

I have an idea, how to check availability of "id_rsa.pub" for each user in home directory. But something does not work. My script: #!/bin/bash users=`ls /home/` for i in "$users"; do if [[ -f "/home/$i/.ssh/id_rsa.pub" ]]; then echo "All…
Piduna
  • 1
  • 3
-1
votes
2 answers

Uniq by two columns with two conditions

i have table with columns. In first column, i have time, when the user has logged, in second column, i have a name of user. 13:15:39 fxs1cia1qulm1lk 13:15:39 fxs1cia1qulm1lk 13:15:39 fxs1cia1qulm1lk 13:15:42 faaaa2aa11111 13:15:49 …
Valeriu
  • 57
  • 2
  • 9
-1
votes
2 answers

bash script to detect when a file is added to folder and command exec

I am trying to write a script to detect whenever a file is added to a specific folder and run a command using the last file added name. What I am specifically trying to do is to create a QR code for each file I add in a specific folder. So what I…
BashN00b
  • 13
  • 1
  • 4