Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

0
votes
0answers
1 views

Back-up script via bash — issues with file paths?

I'm trying to run a back-up bash script in via Plesk scheduled tasks on a CentOS GoDaddy Managed Dedicated Server. I'm having a frustrating amount of trouble with this (made worse by the fact that it ...
1
vote
1answer
18 views

Move thousands of jpg files into daily directories based on the files EXIF creation date

I have thousands of jpg's and mp4's that need sorting into a directory structure which name is based on the date the picture was created. Preferably from the EXIF date as the files modified date might ...
0
votes
4answers
26 views

search a command in PATH with the same name of the script

For example, my script is $HOME/bin/sudo. I'd like to search for an executable in $PATH with the same name, sudo, and run it - but not the script $HOME/bin/sudo itself, otherwise I will run into an ...
2
votes
2answers
100 views

Shell script to assign values from a lookup table is too slow

I'm trying to assign some variables from a lookup file with a shell script. I have something working but it seems unnecessary slow. Script: while read line do ...
0
votes
0answers
12 views

Sudo command not found, error in jenkins execute shell

When I am executing a command in jenkins job (execute shell) with sudo, it throws an error like this: ..../bin/sh -xe /tmp/hudson7505852448142784880.sh + sudo whoami ...
0
votes
2answers
26 views

How do i Reverse output already piped from sort and cut commands

I have to take user input of there UID then use it to reference the /etc/passwd directory and sort the data by first name and display only username,firstname,lastname in that order. The problem i'm ...
-1
votes
1answer
56 views

How to insert the entry into the newline? [on hold]

I have the following entry in a tab delimited file test1.txt key1 10|15 20 30 11|XXX 21 31 Is there any way I can transform this file into the below format? I would like bring pipe delimited values ...
1
vote
1answer
26 views

Start a background process from a script and manage it when the script ends

I'd like to run and configure a process similarly to a daemon from a script. My shell is zsh emulated under Cygwin and the daemon is SFK, a basic FTP server. For what matters here, the script ...
-1
votes
1answer
21 views

Old script on systemV

I want to add a group for permit user belong to group to shutdown the machine system is old sysv unix,with old bourne sh. I did { groufind=`groups|grep system|awk '{print $2}'` } groupscheck ...
4
votes
1answer
65 views

While command not found and syntax error near unexpected token [on hold]

I am trying to write a shell script that takes a string input from a user, asks for a file name and reports whether that string is present in the file. Below is my current script. #!/bin/bash while ...
4
votes
1answer
36 views

inotifywait - get old and new file name when renaming

I'm looking for a reliable way to detect renaming of files and get both old and new file names. This is what I have so far: COUNTER=0; inotifywait -m --format '%f' -e moved_from,moved_to ./ | while ...
12
votes
6answers
824 views

Simultaneously calculate multiple digests (md5, sha256)?

Under the assumption that disk I/O and free RAM is a bottleneck (while CPU time is not the limitation), does a tool exist that can calculate multiple message digests at once? I am particularly ...
0
votes
0answers
19 views

How to set up the permissions using the CUPS backend?

I'm trying to write a script that takes command line parameters and parameter order, formats the output from CUPS server backend query, and configure the permissions and locations to install the ...
3
votes
2answers
34 views

Help with iterating fieldA in CSV file, where fieldB has specified value

I've been trying to setup a script to run on gitbash, to process a CSV file so each record that has a specific value, the last field is changed from empty ("") to a value that iterates from 1 to 16. ...
0
votes
0answers
22 views

Copy old cert files and keep the directory path on server

I need to copy old certificate files to new temp directory but keep the directory structure. The certs files are in directories on the server and need to copy all to a temp folder before removing. So ...
0
votes
1answer
39 views

Read line from file, manipulate, and then append to another file

To pool specific content from a batch of files, I do for ID in {92..128}; do sed '3q;d' directory_$ID/stats done Now what if want to put the $ID in front of each line read (preferably shifting ...
1
vote
2answers
26 views

Replace text/string with new line

I have had a requirement where I need to move data to a new line based on a text: Input :61: 456 B66666 :61: 878 N78777 :61: 534533534 BNNN Output :61: 456 B66666 :61: 878 N78777 :61: 534533534 BNNN ...
0
votes
3answers
28 views

How to print loop index to a file using awk?

I'm a new in bash scripting. I need a help in how to print the loop index to a file using awk? Here is the code I used. echo "Write the start and end file number:" read sta end echo "$sta" "$end" for ...
3
votes
1answer
135 views

grep not working in a for loop over a list

I have some log files. And I have a list of user ids. My log files are in a particular format log-yyyy-mm-dd e.g. log-2014-09-30 I am trying to search each userId in the log file. This is what I am ...
0
votes
1answer
31 views

How can I write a script which updates a text file?

I have made this script #PACKAGES.TXT array2=( `find . -type f -iname *t?z|awk '{print $1}'|cut -d / -f 3` ) funzioneZ() { echo -e " PACKAGE NAME: $i " } array3=( `find . -type f -iname *t?z|awk ...
1
vote
3answers
48 views

Remove patterns from string using bash

I'm trying to remove some patterns from a file input string (parsing file line by line). Here is a sample string: 1: (10/17 12:49:31.175) - CONSTANT ID1 - CONSTANT ID2: RAW DATA OUT > ...
1
vote
2answers
37 views

find a specific string pattern from a file in Unix Shell Scripting

I have the below command. unzip -p GLP.K4C.S06F5.BG57218-rdf.zip | grep ":taxonomies-" | head -1 which gives me the output as, <j.2:Taxo_Version ...
1
vote
2answers
46 views

How to find the process with maximum file descriptors?

What is wrong with this for loop? I am trying to find which process has the maximum number of file descriptors. The first command in the for loop ps aux | awk '{print $2}' prints out only the process ...
0
votes
1answer
33 views

Howto adapt this bash construct to a sh valid construct

On converting some bash scripts to a platform where only /bin/sh is available i'm stumble about this bash construct: #!/bin/sh RSTPD=/sbin/rstpd RSTPCTL=/sbin/rstpctl RSTP=0 ...
0
votes
0answers
24 views

Unix Shell script to delete all traces of itself after execution through crontab

My Question has 2 parts. Help with both parts is greatly appreciated. GIVEN INFO: - Lets assume there are 2 Folders, Folder A and Folder B. - Folder A contains many files. - Folder B contains the ...
3
votes
1answer
38 views

Is checking for exit status other than 0 after a `command || return` unreachable?

I am a shell script beginner and found the following patch of code: function some_fun() { #[...] [ -d ${MKAPP_BUILDDIR}/tmp ] || mkdir ${MKAPP_BUILDDIR}/tmp || return 1 if [ $? -ne 0 ]; ...
0
votes
1answer
41 views

how to delete specific characters in a txt file

Please i need some help! I have these lines in a txt file: 1 Q0 /home/nikol123/Downloads/Ergasia_1/Ergasia_1/metadata/13/120411.xml 1 1 Q0 ...
-2
votes
1answer
43 views

How do I automate this in a shell script?

I'm using the application PlexConnect on my home server (a headless OSX box) and I have to ssh in (from an iMac) and manually kill the Python process sometimes with the following: ssh 192.168.0.7 ...
0
votes
0answers
15 views

Shell script to monitor log files going over a certain size [duplicate]

Due to another issue I'm tracking down, one of my app servers occasionally starts generating a large amount of errors and then becomes unresponsive. For now, the simple solution is to restart the ...
2
votes
2answers
171 views

Shell script written in a different shell than what my current shell

If the shell script is #!/bin/sh But the value of my $SHELL is ksh. Will it make a difference if I changed my ksh to sh, and then executed the script. ie. will a script have different behaviour ...
0
votes
0answers
23 views

Move large number of files in a directory into Subdorectories [on hold]

I've had to perform a file recovery operation recently. I've successfully run a recovery program, but it's left me with a single directory of nearly one million files, most of which are fud. I'm ...
0
votes
1answer
34 views

CSH - How to check if input is NOT number

Please help, I can only see forums with this question for Bash, KSH, and others Need to apply it on csh. to check if the inputted $2 is not number nor the word "all" if ($#argv == 2 && ($2 ...
1
vote
3answers
87 views

How to sum match numbers

I'm new at scripting, and need some help. Will appreciate your answers. I got this assignment, which is to find the sum of all five-digit numbers (in the range 10000 - 99999) containing exactly two ...
0
votes
1answer
49 views

reading file using for, while - behavior

Consider the below scenario 2 vms - 192.168.229.131, 192.168.229.132 Both the vms has it's ip as 192.168.229.151 & 192.168.229.152 in it's /etc/hosts file Say there are around 50 vms like i ...
0
votes
1answer
35 views

Please help me to debug this notify-send battery alert script

I used crontab -e to define the following: */5 * * * * env DISPLAY=:0 /home/max/.bin/battery-check.sh The contents of the script are: #!/bin/bash ...
1
vote
1answer
74 views

Running commands after ampersand symbol & in a remote ssh session

I have a shell script that initiates a long, resource-intensive command on several different machines. In order to execute the script on each machine in parallel, I have an ampersand symbol after ...
2
votes
2answers
41 views

Optional arguments after or before the mandatory arguments?

I'm creating a shell script and I need it to take two mandatory arguments and one optional. How do I check that? In most scripts I've seen, the optional arguments are passed before the mandatory ones, ...
-3
votes
0answers
19 views

Bash Script for checking if an Oracle DB is UP or Not? [closed]

Any shell script for checking the oracle DB is up or not !!! apart from nagios plugins available?
0
votes
1answer
31 views

How to use commands on files that start with “-” [duplicate]

I'm having trouble using using commands on files that start with "-" (i.e. -file 1, -file 2). It is giving me invalid option errors. For example: cp '-file 1' '-file 2' However, echo still works. ...
1
vote
1answer
19 views

To print execution time of Script from Script?

I'm searching PDF files in all directories except those in .texpadtmp by code originally based on this discussion. function findpdfs() { find . -iname '*.pdf' -not -path "*.texpadtmp*" | while read ...
2
votes
1answer
29 views

Why am I getting “too many arguments”

Here's a part of my script that is telling me that I have too many arguments on line 3: #!/bin/bash export LC_ALL='C' if [ `echo "*file 2" | grep -o ^.` = '.' ] then echo success fi Anybody ...
2
votes
1answer
29 views

date command, going back one or two days. Seeing different flags

I'm writing a bash script that should run on OSX and Ubuntu. I'm not sure if this particular problem is due to an OS mismatch; more likely it's a difference in the date command on the two shells, ...
0
votes
1answer
50 views

Bash error: “[y command not found” [duplicate]

I am trying to get this script to function correctly but I get ./passmark.sh line 7: [y command not found. Here is my script #!/bin/bash # A simple script to ask a user for a pass mark and then ...
0
votes
1answer
67 views

How to update specific row and column using awk? [closed]

I have the index file as below key1|3|8|13|24|07:29:29|1111989 key2|6|11|16|16|20:21:19|2565 key3|3|8|13|3149|07:24:36|2930 format: keyn|index1|index2|index3|value1|value2|value3 based on the ...
1
vote
1answer
49 views

count matches and mismatches group by

Please help with a shell script of the following. I need count number of consistent variables in each lane (col1) across samples (col2). For example, since all the values (col4) of lane1 variable 1 ...
0
votes
2answers
114 views

proper way to iterate through contents in a directory [duplicate]

I need to iterate through every file inside a directory. One common way I saw was using the for loop that begins with for file in *; do. However, I realized that it does not include hidden files ...
1
vote
1answer
34 views

How can I maintain line breaks in body text with mailx when sending attachments?

I have a script that emails the text of a log file as the body of the email. That log file has some blank lines between lines of text for readability. When I use the following line in the script, ...
47
votes
2answers
3k views

Shebang starting with `//`?

I'm confused about following script (hello.go). //usr/bin/env go run $0 $@ ; exit package main import "fmt" func main() { fmt.Printf("hello, world\n") } It can execute. (on MacOS X 10.9.5) $ ...
1
vote
1answer
31 views

Apt-get failing in bash script?

I have several machines (running Ubuntu LTS 12.4 64-bit) which need to be configured in the same way, so I created a shell script which will run automatically the first time the machine boots. It ...
-1
votes
1answer
25 views

What is the easiest way to count the amount of letters in a string entered

I am currently writing a program in the raspberry pi that will allow a user to enter a string, and have the program count the amount of letters in it. I am looking into expr but I don't know how to ...