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
-2
votes
2 answers

Shell Scripting in Linux

How can I move few files that contain spaces to another directory using a bash script? file name: "Sublime Text 3.x" my code is : for file in $(ls -t | tail -n +1) do mv $file /tmp/test done Output shows as: mv: cannot stat ‘Sublime’: No such…
Anas KK
  • 5
  • 1
-2
votes
1 answer

Write Python Output to File in Cronjob

I have a script (/home/user/script.sh): #!/bin/bash /usr/bin/python /home/user/program.py >> /home/user/logs/out.log & and it is working. The output from the python script is written to the out.log file. Now I am adding the script to cron: */1 * *…
inq93
  • 1
  • 1
-2
votes
1 answer

Script to remove suspended accounts automatically from Linux server

I have Linux hosting server with centOS, which have WHM installed on it. To reduce the costing and mis-usage of Disk space i am creating a shell-script which automatically removes the suspended accounts which are suspended for more than 30 days and…
imvikasmunjal
  • 753
  • 7
  • 14
-2
votes
1 answer

How to insert text from a file into another in bash

The content in fileA is: Here’s the ip list. ip: 2.2.3.4 ip: 2.2.3.5 ip: 2.2.3.6 ip: 2.2.3.7 The content is fileB is ip: 1.2.3.4 ip: 1.2.3.5 ip: 1.2.3.6 ip: 1.2.3.7 How to use sed command or other commands in a bash script to produce a list…
Purres
  • 239
  • 1
  • 4
  • 18
-2
votes
1 answer

how to write a script to get ifInOctets and ifOutOctets?

Can any one help me with writing a script to get ifInOctets and ifOutOctets from a server 10.38.2.24 ? I need help
Ali
  • 9
-2
votes
1 answer

case + how to implement equal or less or greater in case syntax

my target is to verify the range of number with (only with - case + esac ) , and print the range so for example if number is between 0-80 , case will print >=0<=80 or if range is between 81-100 then case will print >=81<=100 and so…
yael
  • 2,433
  • 5
  • 31
  • 43
-2
votes
2 answers

How to create a script to check logfile

I want to create a script where i check the logfile every 5 or 10 minutes to know if the service is up and running, and also, to know if the logfile is receiving and sending these files that are being received (more like if a new file enters in the…
Jhony
  • 1
-3
votes
1 answer

Find the overall disk size of a linux server

i have a requirement to check the overall disk size of a linux server. is there any shell script to find the overall disk size. example: serverA -- allocated with 5 disks of below size sda - 100G sdb - 200G sdc - 200G sdd - 500G sde - 1TB overall…
subash ct
  • 1
  • 1
-3
votes
1 answer

Function, that check previous command

i want to write fucntion, that check previous command. Succes or not. My code: #!/bin/bash function check_previous { RESULT=$? if [ $RESULT -eq 0 ]; then echo "success" else echo "failed" fi } echo…
Valeriu
  • 1
  • 2
-3
votes
1 answer

Are these Advanced Features possible with a Bash Script on an Ubuntu Server?

I am trying to build a really flexible and useful Server Backup Bash Script. I have pretty much no experience working or building Bash scripts. I know that thousands of them exist in the wild but I want a more customized one that has the most of…
JasonDavis
  • 2,658
  • 6
  • 25
  • 32
-3
votes
2 answers

perl one liners + add empty line after the last line

please advice what need to change in the perl syntax in order to add new empty line after the last line? example IP_INFO=12.23.2.1 echo IP= | perl -pe "s/$/$IP_INFO/" 1>>file . more file IP=12.23.2.1 <-- last line
yael
  • 2,433
  • 5
  • 31
  • 43
-3
votes
1 answer

linux + count how many digits in IP address

I write the following syntax (exist in my ksh script) in order to find how many digits I have in IP address IP_address=127.1.1.1 echo $IP_address | sed s'/\./ /g' | wc | awk '{print $2}' 4 . IP_address=127.1.1 echo $IP_address | sed s'/\./ /g' |…
yael
  • 2,433
  • 5
  • 31
  • 43
-3
votes
2 answers

Split List of ids in to integer and string?

I am having a list of ids (total 2 lakh), I want to write a shell script to split the ids (string and integer) using shell script . Example given below : IDlist.txt: | LT345 | | R567 | | LT9 | | MRTD002 | | MK53 | |…
ara
  • 11
  • 1
  • 2
-3
votes
1 answer

bash + create proccess from function before program ended

the following short bash program described how to execute the func1 by process ( func1 & ) func1 is function that do some tests and verification on Linux machines And this program run after reboot from /etc/rc3.d I want to ask if it possible to…
yael
  • 2,433
  • 5
  • 31
  • 43
-3
votes
1 answer

how can execute complicated linux command inside perl

#!/usr/bin/perl @HOSTS = ("192.168.14.112", "192.168.14.90", "192.168.160.1", "192.168.160.100"); my $COUNT = 4; my $date =`date`; for my $myHost (@HOSTS) { **$count = `ping -c $COUNT $myHost | grep 'received' |awk -F',' '{…
user1363308
  • 101
  • 1
1 2 3
41
42