A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
0
votes
2answers
17 views
Usage of consecutive variable names in a script
I want to do some simple calculations with variables in an script.sh, in the same directory there is a folder called New Folder2. So, I want to enter into the folder and save a text file.
The script ...
1
vote
1answer
32 views
Why can't I execute this script?
I am trying to execute a script to determine its system running time and potentially fix its problems.
If I type:
{hostname@bankofamerica]$ ./xx-xxx-xxxxx.sh
[sudo] password for hostname:
_
It ...
1
vote
2answers
25 views
combining 3 separate arrays to one multidimensional array in bash
Is possible to create multidimensional arrays in bash scripting?
These are my 3 arrays:
arrayCITY=( NewYork LasVegas Detroit )
arraySTREET=( RoadStreet TreeStreet HighStreet )
arrayNUMBER=( 20 455 ...
0
votes
2answers
31 views
Trying to figure out Linux script
I am a fairly new Linux user and I am trying to put a script together for a class.
The script is supposed to allow a user to type in a username, and it will say if the username exists or not. If it ...
2
votes
3answers
60 views
awk system call with inverted effect
I have a data file with multiple data blocks enclosed between specific keywords (DATA,END). I am using awk to extract the data blocks into separate files, based on a file name taken from said block.
...
-3
votes
0answers
27 views
Speeding up Linux scripts in vim [on hold]
I am trying to speed up our .sh files that are insanely slow. What are some number of ways to run the whole script or a subset of scripts in a faster and robust way?
Thank you! and I really need HELP!...
-1
votes
0answers
27 views
How to run shell commands at startup [on hold]
I am using openwrt on my board. At startup, I need to run command for taking serial data and send it to an IP. The command is:
socat FILE:/dev/ttyUSB2,b57600,raw,crnl, TCP:192.168.1.1:5001
How do I ...
1
vote
4answers
62 views
How to check if a variable entered is alphanumeric or not in ksh?
I am using ksh on AIX and I want to check if a variable, for example var1=sanySAN, var2=SANYsa%$3 is alphanumeric or not.
Here, var1 is alphanumeric and var2 is not. I know I can use [a-z][A-Z][0-9] ...
0
votes
1answer
11 views
Replace an open bracket ( with !( Only at a specific location wrt a -> symbol
I want to replace only a specific bracket with not of that bracket i.e !( And this bracket should be the one right before this -> sign in each line of the file.
For instance,
(A & b) -> (b &...
2
votes
4answers
43 views
List files not stored in Git repos
I want to find out what files in a certain directory are not managed by Git. This is so I because I use Git for backups, and I want to eventually get all my files personal in there.
What unix tool ...
-7
votes
0answers
27 views
LINUX SHELL SCRPTING' [on hold]
While unzipping a directory using unzip command the folder is getting unzipped in previous directory./
0
votes
1answer
21 views
Check if multiple directories exist with bash script [duplicate]
I have a file with a list of directories and I need to find out if they actually exist on the system. It's quite a large list so I'd like to figure out how to automate the check.
The file is ...
0
votes
4answers
45 views
How to use as argument the characters + , - , x , / in a script [duplicate]
I am trying to write a script I will call calc.sh that does basic calculations using the arguments for the script ( $1, $2 and $3). For instance I'd like to get 2 as result for
./calc.sh 10 / 5
My ...
3
votes
5answers
89 views
Get the query string from URLs in a log file
I have a server log file that contains a number of log entries in the following format:
193.1.172.46 - - [23/Mar/2008:03:57:38 +0000] "GET /robots.txt HTTP/1.0" 404 289 "-" "gsa-crawler (Enterprise; ...
3
votes
1answer
39 views
Problem with strongSwan
I have a VPN server with Ubuntu and IKEv2 protocol using strongSwan.
We create clients using the bash user.sh script, but we have a problem as shown below.
When the number of clients increases - to ...
2
votes
1answer
25 views
Record of highest NF
Using awk for the following input file, how could I take the record with highest NF for the same last field.
File:
5541,55004,919843,IND
5542,5541,55004,919843,IND
7903,790287,RUSE
7905,7903,...
1
vote
2answers
22 views
How to automatically run a script when I connect a bluetooth device?
I have a bluetooth headset and I need to execute a .sh file everytime I connect it to make it work. I don't want to troubleshoot this bug since I know there's already people looking into it.
But I'm ...
-3
votes
0answers
19 views
how to reset user password my multiple unix or linux server. using shell scripts [closed]
here is the problem :- how can reset user password of my rehal 7 solries 10, 11
also i have to use to exception handling. how to log in the server. in staring for checking username is exist or not. ...
1
vote
1answer
29 views
Match EXACT string in file and update IP Address
There two steps, first check if exist the host in the file
If have the file:
# FILE: /etc/hosts:
192.168.0.10 srv-db srv-db-home
192.168.0.15 srv-db1
192.168.0.20 srv-db-2
192.168.0.20 srv-db-work ...
1
vote
0answers
18 views
Ansible, trying to find a way to force a task time out on a host it's currently operating on
Concerning Ansible, this should be fairly straightforwards I hope:
Scenario:
I have 3 servers, red, green, and blue.
I have a task created for ansible to use yum in linux to install a random ...
0
votes
2answers
45 views
How to list all zip files in a directory? [duplicate]
Ubuntu 16.04
I tried this:
for file in $source/*.zip
do
echo $file
done
and it works if the directory contains zip files. It prints out all them. But if it does not, it just print the $...
1
vote
0answers
12 views
Warn in crontab if command has failed multiple consecutive times
I have a command in my crontab to monitor a service (specifically, check whether the Tor version of my website can still be accessed): this monitoring command succeeds if it can access the site, and ...
1
vote
1answer
16 views
How to measure time of multiple commands in background?
I have a shell script with multiple commands and I want to run each command in background, so I put an & at the end of each command. I need to measure how much time execution of all the commands ...
3
votes
2answers
52 views
Create a script to identify those users who have not logged in the last 15 days
I have doubts:
The exercise is:
Make a script to detect users who have not logged in in the last 15 days AND belong to group "alumnos". The list will be added to /var/log/alumnos_sin_login.
My ...
0
votes
3answers
44 views
How to run bash script as long as video length?
How to run bash script as longs as video length?
I will set up a cron to start bash script at 7PM, and I want to keep it running for as long as video length. How to do It?
Example: 7PM bash scripts ...
0
votes
0answers
33 views
Restart a running process if it outputs a particular string?
I want to loop a process in a bash script, it is a process which should run forever but which sometimes fails.
When it fails, it outputs >>747;3R to its last line, but keeps running.
I tried (...
3
votes
2answers
52 views
Expect script for copying file
I am trying to move/copy some files from my local machine to another host which I am able to access via ssh. But unfortunately this below script is not working.
when I run this script it is asking me ...
3
votes
4answers
65 views
How to move a file recursively based on size and keep structure
I want to move files bigger than "300Mb" from one directory tree where each file is located in subfolders
Example: I have a directory structure:
dirA/
dirA/file1
dirA/x/
dirA/x/file2
dirA/y/
dirA/y/...
0
votes
1answer
25 views
How to read simultaneously from two files and print them line by line, bash? [duplicate]
I want to write an script which has as arguments two files F1 and F2 and prints them alternatively; first will be written F1's first line, then F2'2 second line and so on. If one of them has less ...
3
votes
0answers
38 views
Perform dig on two lists
I need to run a dig on domains and these domains aliases, so the result will be:
IF domain (+ doesn't have an alias) and is using my Name Servers -> then print out
IF both domain and alias are using ...
2
votes
3answers
38 views
Piping a command's output to a variable in body of awk script
Given inputfile
Cherries:20:100:300
Beans:12:400:500
Tomatoes:32:445:234
Potatoes:24:400:200
Kiwis:23:230:435
I have an awk script, named testscript.script:
BEGIN{ FS = ":"
print "-----------------...
1
vote
1answer
23 views
Extract two values from files
I would like to extract two values from a series of .txt files.
This is the last two lines (line 49 & line 50) of my .txt file
1 13593 3434 2.2585 0.9
2 3333 333 3.7118 0.8
& I want ...
2
votes
1answer
75 views
Creating script with looping in same screen
I have one simple problem, with my script, I need row script in same screen and does not display last information above, see my demo code:
#!/bin/bash
if [ -t 0 ]; then stty -echo -icanon -icrnl ...
1
vote
0answers
13 views
Multiple spreadsheet from one xls [closed]
Can we create one multiple spreadsheets from different xls file using shell script. I created using xml in shell script using , But the one spreadsheet will open when all the xls files are present in ...
0
votes
1answer
19 views
execute command on a host from a file with a user from another file
I am trying to create a script that would login to each server from a list with a user from other list and execute a command. How can I do this by taking the first host from the file and login with ...
0
votes
0answers
31 views
Why can't I print to terminal with my python script? [migrated]
I can't figure out why I can't print to the terminal using the following code.
#!/usr/bin/env python3
import sys
def main():
sys.stdout.write("Hello")
I'm running the program from the terminal ...
1
vote
3answers
152 views
Find pattern and remove it from all files [closed]
Please help me solving following problem. Remove all pairs of characters \ n from Test_Macro in all files. Please see below example:
Fil1.txt
Test_Macro(abc, def, "\n string1 string2 \n test string",...
4
votes
1answer
186 views
How to delete files from another server using a shell script
Suppose we have two servers 'A' and 'B'.
Server B:
Directory structure: /a/b/c/
The above directory has the files below:
2016xzy
2016abc
2016pqr
2015ghj
I want to delete all files which ...
-1
votes
0answers
22 views
how to read the hive table rows in to this query and result also stored in separate table
Actually the input records are coming from the hive table and the output records also will store it in split table.
Modifications:
date split is fine. need to split the val2 value also as per the ...
0
votes
2answers
45 views
Tool to replace block in a file
Most configuration management software tools have a way to replace a block in a file.
Example:
SaltStack: blockreplace
Ansible: blockinfile
I want exactly this, but without the overhead of these ...
1
vote
1answer
24 views
Parsing file in linux : store timestamps only
I have 31 files in one directory.
File format is as below :
TimeStamop user-id
1471417712595 1936f35c-XXXX-XXXX-XXXX-49898523b8ea
1471417717238 e3153e8d-XXXX-XXXX-XXXX-7710089c77bb
...
21
votes
4answers
2k views
How do I replace and (&&) in a for loop?
I'd like to execute find an equivalent of
cmd 1 && cmd 2 && ... && cmd 20
But with commands expressed with a for loop:
for i in {1..20}
do
cmd $i
done
What would you ...
1
vote
0answers
12 views
Setting up working environment - Konsole or other terminal - open few tabs and run some commands
I have a working environment where I run a web server, TSC compiler, and then work in few directories in a console, and also run few programs - IDE, 2x gitk, krusader.
I would like to be able to ...
3
votes
2answers
263 views
Check if a file exists on a remote machine with spaces in the filename and/or path
I have a simple bash script; I basically want to make sure that the file exists on a remote machine. I've found numerous examples of how to do this, but the missing component is how to do this with ...
0
votes
1answer
30 views
Rsync behave differently if invoked inside script
So, I'm writing a backup script, and wanted to skip .iso files.
If I use the command from the command line, everything works fine:
rsync -a --delete --exclude='*.iso' /home/user/Desktop/Work /mnt/...
0
votes
3answers
43 views
Date Difference Calculation [duplicate]
I am looking to calculate time difference between the two below
Value1=2016-10-13 14:19:23
Value2=2016-10-13 18:19:23
I want to get difference in the form of hours/minutes. Any quick solution ...
6
votes
3answers
615 views
* at end of directory path
I'm pretty new to Unix so please bear with me a bit. I have a question about the * character at the end of a directory path in a bash script.
I have a script that's supposed to automatically delete ...
-3
votes
1answer
125 views
find and ls output
I am having trouble trying to output all my .mp4 films into a text file, it works but there are a few quirky things occurring and I am not sure why.
Here is the cmd.
find "/volume1 HD FILMS" -iname "...
0
votes
2answers
41 views
Script to move all files in a dir (and subs) to a new folder based on extension [duplicate]
I had to recover a micro-sd card using photorec. I'm left with a dir that contains lots of other dirs which also include multiple file extensions. I would like to move each file to a new dir based on ...
0
votes
1answer
50 views
How to import python variable in shell script
I have a shell script like below.
If I have a test.py that has a variable a=5, how can I import the variable to the following shell script?
python test.py
b=10
if [ $a == $b ]
then
echo "a is ...