A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

7
votes
3answers
120 views

Remove certain characters from multiple files with whitepsaces

I'm trying to rename a bunch of music tracks in a directory, but I got this error: When moving multiple files, last argument must be a directory This is the script: for file in * ; do mv $...
2
votes
1answer
88 views

Programmatically change the attributes of desktop icons

Whenever I happen to add / remove an icon from my (Cinnamon) desktop, the others either get shuffled seemingly at random, from being sorted by name or resized, or at least the new icons will be ...
5
votes
2answers
25 views

maintain prompt despite ouput flow

Short version Can I maintain an input symbol (> for instance) at the bottom of the terminal so that the user can input despite text flowing above? Long version I am making a multi-process ...
2
votes
3answers
763 views

bash - get pid for a script using the script filename

I have two scripts: running_script script_one I need to get the PID for the/any instances of running_script running under a username, and then pkill to stop the running_script and daughter ...
0
votes
2answers
35 views

I'm trying to pull all the text past one point in a file and print it on the screen using bash

This is my input and output: cat /home/$USER/Downloads/cudaHashcat-1.37/cudaHashcat.pot | grep : $6$Tgjtsn2v$dT2el6ZxY9ADYl2WlZE6UdCkDyczwztDoXvtym6KEZv6vkZjNHDbTv.vTVHeQSIrt61uWpbD/gisf3bcET8VK.:...
4
votes
2answers
153 views

Read quoted array elements with spaces from file?

I'm passing data from STDIN into an array using read like so: prompt$ cat myfile a "bc" "d e" f prompt$ read -a arr < myfile But read doesn't appear to pay attention to the quoted strings and ...
4
votes
1answer
183 views

Is there a way to activate a particular tab of chrome via bash?

Suppose, for example, I have a chrome window active with gmail opened somewhere among its tabs (but not necessarily the active tab). Question: Is there a way to activate the gmail tab from the ...
4
votes
3answers
149 views

Use terminal-based documentation effectively (no web browser) [closed]

The problem I was trying to find shell scripting information without an Internet connection, i.e. via man page. Specifically, I was looking how to pass and use parameters. man bash does not contain ...
2
votes
3answers
53 views

need to move files with name into directories with corresponding names

I have files named patient_sample_L001_R1_001, patient_sample_L002_R1_001, patient_sample_L003_R1_001, patient_sample_L004_R1_001 another set named patient_sample_L001_R1_002, ...
2
votes
1answer
125 views

How can I get the correct end time of a nohup command?

#!/bin/sh set -x echo "Starting Time at "`sshpass -p xxx ssh -o StrictHostKeyChecking=no UN@IP 'date'` nohup ab -n 20000 -c 70 https://xxx.xxxxxx.com/xxx/xxxx/new.jsp & echo "Ending Time at "`...
1
vote
2answers
90 views

Linux; run script when a specific host becomes reachable (logs in on AP)

I have a Debian Linux running on a RasPi. I'm looking for a way to run a script when another system becomes available on the network (aka logs in on my wifi AP). The AP is an AVM Fritzbox and as such ...
-3
votes
1answer
72 views

Please help assess what's wrong with my script

I'm attempting to create a script that loops through an entire directory of files in order to find the file with the most characters in that directory attached is my code sample. What am I doing wrong?...
2
votes
1answer
99 views

Conditional Execution - Launching Persistent Sub-Processes and Coroutines

Conditional execution is used in Bash to control the flow of a script on the basis of the exit status of a subprocess. However, there are situations when a subprocess (application) is launched in the ...
2
votes
2answers
48 views

Help required to execute shell script

I need to write a shell script to see if the ADM Process is down we need to get an alert via email. I have done that using the script below. It is working fine if we have installed one ADM server on ...
0
votes
3answers
60 views

Need to write a “thirsty.sh” script: BASH [closed]

Okay I have all of the code and it's working. I am just having trouble with the while loop #asking the user if they are "thirsty". echo "Are you thirsty?" #creating thirsty variable read thirsty ...
2
votes
1answer
83 views

Unix ffmpeg Shell Script merge .aif and .mp4

I need a script that merges multiple files (.aif and .mp4) in the same folder with the same name to a new folder called [original_name]_new.mp4 Code: #!/usr/bin/env bash -e function combine(){ ...
1
vote
1answer
416 views

Skip first line (or more) in CSV file which is used to rename files

I have used the info from another question on Stack Exchange to allow me to rename files using the info in a csv file. This line allows me to rename all files from the names in column 1, to the names ...
2
votes
1answer
182 views

Cut command does not separate by tab in script

Note : I don't know how to insert tabulation in my text, I replaced it by [tab] I have a list file name value separated by a tabulation : host1[tab]ip1 host2[tab]ip2 host3[tab]ip3 host4[tab]ip4 ...
2
votes
3answers
85 views

Bash script to echo the first positional of each line into file with name of the second

I have a text file that is organized as follows: Group 1 asdsdsdsdf.html jeff xcvxcvxcvx.html bob vrgeiuvhif.html sue Group 2 iwdowijdoi.html mary pokpompojm.html doug ndkjfsjfbs.html lisa I ...
6
votes
6answers
725 views

bash: how do you return file extensions?

I want to write a script to return just the extension of the input file name. For example, textfile.txt should return txt. I'm new to Linux and bash, and I'm trying to learn how to write basic ...
1
vote
3answers
42 views

Bash script processing snmp text to only print desired ID

I am trying to create a bash script handling snmp responses the same way wether or not the OID is installed on the client. Clients can get the following responses: SNMPv2-SMI::mib-2.47.1.1.1.1.13....
1
vote
1answer
210 views

BASH AWK Script add days to fixed date

My task is to export data from a database with the UNLOAD TO statement in dbaccess and convert it into a file, that can be inserted into a similar database. Now the problem: The old database (let's ...
0
votes
1answer
29 views

Script add's md5sum to duplicate filenames but still get error notifications when executed

So by using some info from other threads on this site I have managed to get a script to copy files to another directory, then add the md5sum into the duplicate file names. However, I'm not fully ...
0
votes
1answer
43 views

Ignore parts of script under some circumstances?

My script looks like this strenggen ( ) { something; } strengen 1 strengen 2 strengen 3 strengen 4 strengen 5 etc.. Which adds a few files to the directory called strengen?string=1, strengen?...
0
votes
3answers
258 views

How to split a “one-line text”, based on pattern? [closed]

I have a 1 line file ,contains non graphic characters and I want to split it based on a pattern. My pattern is \[0-9][0-9][0-9]; how can I do it? For example, I want to split this line: \001abd \...
2
votes
2answers
77 views

echo the directory with the information

The following script is working, I would like one more piece of information to the result. Besides the service rtvscand status, I also want to add where the file resides. Like: the symantec file ...
3
votes
2answers
88 views

Remove all but the latest backup file monthwise

I've got a directory, containing lots of weekly generated files with names like db_20130101_foo.tgz db_20130108_foo.tgz db_20130115_foo.tgz ... and so on. Over the years, the disks will get ...
2
votes
2answers
782 views

RHEL 7 how run longtime script before shutdown/reboot systemd

I'm trying to found solution how run script before shutdown/reboot is initiated in RedHat7. I need to correctly shutdown SAP database when I'm shuting down or rebooting server. Script for SAP ...
1
vote
2answers
58 views

Bash Script: No such file or directory when defining variable via source vars.txt

I have a script that creates a hash of a file, writes it to vars.txt and then checks that variable next time the script is run to determine if the file has changed. Here is the script and vars.txt (...
1
vote
1answer
125 views

Get IP Address of Main Interface in Ubuntu and Mac

I need to write a script that gets the IP address of the interface that is used for unknown routes (e.g. where 0.0.0.0/0 is routed through) That script should work on Ubuntu, Debian, Arch and Mac OS ...
0
votes
2answers
125 views

How to check all desired files have been downloaded in shell script

I have downloaded the files from remote server by sftp.now i want to check that all of my files (nodeid given) have been donwloaded or not.if not downloaded then give the warning messages by sendmail. ...
0
votes
1answer
76 views

Script inside bash shell thats inside another bash shell [closed]

I'm trying to run a simple program #!/bin/bash bash echo "Hello World" But the program only gets as far as the 'bash' command on line 2. Why can't the program run line 3? The program terminates at ...
1
vote
1answer
142 views

#! /bin/bash or #! /usr/bin/env bash? [duplicate]

I'm trying to write some provisioning shell scripts for Vagrant dev environment. I'm used to start bash scripts as follows #! /bin/bash But after surfing through some git repos I found out that in ...
0
votes
2answers
117 views

How to loop over each file in a directory, if and only if the directory contains the .csv files?

/dir1/--$ ls 1.txt 2.ssl.txt If the dir1 directory has the given .csv files, then only process the files listed in the .csv in a loop one after another. Here as the dir1 does not have any files ...
0
votes
0answers
77 views

Logging to a file in tabular format

I am trying to print something into a file through the script which will be sent as an attachment to the mail. Now what i am willing is to preserve a proper formatting within the file. Can i print ...
0
votes
4answers
125 views

How to log from inside the script along with stdout

I am aware that I can log using tee But I want to log from inside my script, at the same time display the content on the stdout. Example, my code looks something like this: names=$(print("name1 ...
0
votes
2answers
440 views

Check whether an IP belongs to a specific range

I have a log file that lists whitelisted IP ranges in this manner: "217.29.0.0-217.29.255.255", "204.12.0.0-204.12.255.255", "198.54.223.0-198.54.223.255", I am also working on a bash script which, ...
0
votes
1answer
125 views

CentOS and Stop Shell Script running on screen

I'm trying to automatize my system, sorry but I'm not very experienced on Linux distros, actually using CentOS 7. Every time I restart the machine I need to do: screen -S bun then on that screen I ...
1
vote
1answer
208 views

script can't write to systemd journal

to make it short: I want to write to the systemd journal from a script. printf "%s\n%s\n%s\n" CODE_FILE=/etc/zsh/zprofile CODE_LINE=31 MESSAGE="could not read /etc/dircolors" | logger --journald ...
0
votes
1answer
104 views

Running two commands at the same time?

Here is the nature of my problem: I'm using my raspberry pi to run a wikipedia server, so I'd like to make a launcher (desktop icon) that starts up the wikipedia server and opens the web browser to ...
1
vote
2answers
1k views

Cron Bash Script - echo to current terminal instead of /var/spool/mail/root

Is it possible for a Cron Bash Script to echo to the current session terminal instead of /var/spool/mail/root I have a script which writes errors to a log file but any supplemental/unimportant info I ...
0
votes
0answers
323 views

How to write a script with Android Debug Bridge command in it

I am trying to write a script to automate some testing, and the fist step is connect to my device and update the /lib/modules/ directory with the recent version of a device driver on my host. That is ...
2
votes
1answer
44 views

Launch a command when connected to a host

In a dormitory I live in the access to Internet is somehow clumsy. The procedure follows Connect to the network (via WiFi/Ethernet) Login by ssh sshpass -p password ssh login@domain.edu.pl ...
1
vote
2answers
320 views

What type of file is /dev/core or /proc/kcore?

While scanning a filesystem for changes with a shellscript, I forgot to exclude /dev, so core got tested too. Strangely enough, which ever way I test it, it is not consistent for a type: $ if [ -f ./...
0
votes
0answers
141 views

permission needed for Python to access USB drive?

I got this Python script that reads media files from USB stick. It used to run fine, today it keeps giving me OS Error: [Errno 13] Permission denied: media/myName/usbName when the script runs the ...
4
votes
1answer
72 views

How to find how many windows are opened in GNU screen?

I am trying to automate my work flow. I have a script that opens individual window in screen for each IP in a list. Imagine setupscreen.sh <IP1> <IP2> .... After all windows are open, each ...
0
votes
1answer
76 views

Compare first column of 2 files based on the second column using the delimiter ;

I need to compare below 2 files. The head_file: 2345;int builder( 1000;char type::edit::display <test>( 250;void unamed_string_tree* The ref_file: 2000;int builder( 500;...
0
votes
1answer
52 views

How can I replace a filename with .ear in a file-list using sed?

I have a file whose contents look like: /appl/as/var/spool/ears/mps/ear1.ear ... I want to replace the name of only ear1.ear with ear2.ear and I am using the below sed command, but with no luck: ...
0
votes
2answers
67 views

Grep for string but ignore commented out items with string

I'm looking for the words gmail or outlook in a directory. Although there are some lines commented out with the word gmail and outlook in it. How can I grep for this? I tried a bunch of things but I ...
0
votes
0answers
31 views

Preserve formatting of the attachment sent by the script

I have written a script which at the end of execution send a mail with an attachment. Through my script i am making two files , one serves as email body and the second as an attachment. I noticed ...