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

learn more… | top users | synonyms (2)

1
vote
1answer
59 views

Shell Script does not send email from Cron job [duplicate]

I have a shell script which sends email when the disk is more than 80% full; when I run the script as sh -x script.sh or ./script.sh I get an email but when I keep the script in cronjob I do not get ...
0
votes
1answer
19 views

Have to transform some bunch of csv in req format and store it in some other location with same name

I am having some input CSV files INPUT_FILE: A_B_C_NFM001_20150729.csv A_B_C_NFM002_20150729.csv A_B_C_NFM003_20150730.csv I want output file also with the same name as input after performing below ...
1
vote
0answers
31 views

How to normalize irregular data values

From a PHP table I get the values graphically represented. However some of the data recieved is 'damaged' or incorrect thus yielding a non-sensible graphical representation. The hours (y-axis) is ...
3
votes
2answers
34 views

Cycle between open windows with wmctrl

I have a script that I'm trying to use to make handing applications easier. Right now it gets the window id of an application name (the first parameter) and checks if the window_id exists or not. If ...
2
votes
1answer
45 views

make sure all lines in a textfiles don't have the same value

I have a text file that contain multiple lines. Some of the lines have contain same value. What I want is to make sure that all of the lines do not have duplicates or "triplicates". Sample: ...
2
votes
1answer
41 views

Running compilation scripts only if the source file is more recent than the compiled programe

all. I'm not sure if this question belongs here or some other site but I figured I would start here and some helpful moderator would kick me over if there is a better location. What I am trying to ...
1
vote
1answer
45 views

How do I get a folder name using a wildcard and check for it's uniqueness

I want to move a series of file into different folder based on their ID, but I want to make sure that the folder I'm moving the file to exists and is unique The folders have a matching ID as the ...
0
votes
1answer
60 views

mv: cannot access file

Good day All, I have a script with permissions - 770 root:root script.sh. The scripts has to zip then moves files with permissions - 644 rex:roger file.csv. With a bash one line - mv file.csv ...
2
votes
3answers
140 views

Shell script executed with cron results in different size file than executed manually

I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in ...
2
votes
3answers
167 views

!(*.sh) works on the command line but not in a script

When I use the code below in a terminal on Ubuntu, it works fine: rm !(*.sh) -rf But if I place the same line code in a shell script (clean.sh) and run shell script from terminal, it throws error ...
2
votes
3answers
119 views

Shell script to fetch part of file name from input file and transform it into output file

Source_FIle: /path/to file/A_B_C_D_201507290915.csv Destination_File should be like : /some/other/path/to file/A_B_C_D_201507290915.csv I need to transform Source_FIle and storing with the same ...
0
votes
2answers
33 views

How to run to parallel gnome-terminal windows?

I'm looking to run two independent parallel gnome-terminal windows with some parameters, from 1 shell script. So far I've got this: #!/bin/sh gnome-terminal -e window1.sh & gnome-terminal -e ...
0
votes
2answers
34 views

wget, logging the output and the response

I calling an url using wget. This url gives me a response, its a Message id. I want to write the logs to a log file, with the message id as well. Also the log should be appended each time. I trying to ...
0
votes
0answers
9 views

Audio File Search, Count and Sort - OS X or Synology

There is a collection of audio files on a Synology NAS. Approximately 24,000 albums worth, that I need to analyse and report on. I will need to: Count total number of files Count types of files ...
0
votes
1answer
42 views

How to call variable in KSH shell script

#!/bin/sh # This script if for checking the status of SSHD2 Number of connections CHKOUT="Please also Check the Number of ORPHAN / DEFUNCT Process on `hostname` :" DFOUT=`/usr/bin/ps -eaf | grep ...
4
votes
1answer
57 views

“$@” expansion for user defined variables

I'm trying to get a (bourne shell) variable to expand like "$@" so it produces multiple words with some having preserved spaces. I've tried defining the variable in many different ways but still can't ...
0
votes
3answers
46 views

How do I create a directory for every file in a parent directory

I have parent folder and inside this folder I have 4 files ParentFolder File1.txt File2.txt File3.txt File4.txt I wanted to create subfolders inside the parent folder and ...
0
votes
1answer
58 views

Disable ctrl c and ctrl z while a script is running

I have a script that takes about 45 seconds to run. How can I disable Ctrl-c and Ctrl-z while a script is running?
1
vote
3answers
42 views

Why won't my FTP script get all the files using mget command?

I am having a script which pulls data from different servers whose details it reads from external file. It reads the files and the verbose output shows all the matching files but it fetches only one ...
0
votes
3answers
48 views

prevent repeated emails via bash to overquote user

I need some help to improve the idea/implementation.Scenario is local mini ISP. users accounts are stored in freeradius/mysql. The task is to send user email who have consumed 80% of there assigned ...
2
votes
1answer
20 views

Manipulating RGB values in PNG from command line

I'm looking for a command line tool/script which allows you to balance the colors in a PNG - similar to the "Adjust Color Balance" effect in Gimp (Colors > Color Balance...). Something like this ...
4
votes
2answers
120 views

Run an app with a window manager behind in a separate X server

I want to launch an app in a separate X server. It needs a window manager behind it, though. I created a script #!/bin/sh x-window-manager & my-gui-app and launched it with xinit ...
0
votes
2answers
60 views

How to use cp command in bash script to copy files with spaces ans $ characters in it? [duplicate]

I am trying to copy some files with spaces and $, @ symbols in their file names in a bash script but the script fails to copy the files stating it cannot find the file. I can see that it is treating ...
3
votes
2answers
122 views

Using bash variables in perl command in bash script

I am trying to generate a hashed password as in /etc/shadow file, using bash script. The user is prompted for the password which is saved in a variable PSWD. I have extracted the Hash and the salt ...
1
vote
5answers
361 views

Check number of words in a file that contain a specific letter

Bash command to check number of words in a file that contain letter “a”
1
vote
1answer
43 views

error ./c.sh: line 24: [: too many arguments in shell program

I am trying to make a shell script to print the amount of time user was logged into the system but I encountered a too many arguments error. I tried many methods from the internet but none worked. ...
3
votes
6answers
143 views

How to run no more than n parallel subshells

I am trying to run subscripts from a main script, but I want to make sure than no more than n subscripts run at the same time. The following simplified example illustrates. Each subscript creates a ...
2
votes
1answer
88 views

Issue with ':' character in Bash script over SSH

I am currently writing a script that will perform backups on a set of databases, comress them, encrypt them, transfer them to a separate storage machine, and verify that the file made it successfully. ...
2
votes
3answers
173 views

Remove the ^L (aka \f/FF/form-feed/page-break) character

How do I remove the ^L character and the blank lines that come after it on a unix file? I have tried the below and have been able to remove the VT and spaces but am failing to remove the ^L character ...
1
vote
1answer
48 views

How to use SFTP in a script to non-interactively pull file from remote host?

I want to use a shell script to pull a file from another server. I have written a script where i can do this but i want the script to work non-interactively so that it doesn't prompt me for the ...
1
vote
1answer
63 views

Reload network interfaces without rebooting

I'm doing a BASH script for Arch Linux in a Raspberry Pi 2. The thing is that in some point I'd like to reload the network interfaces without reboot and have my new named network interfaces (en0 and ...
1
vote
2answers
47 views

Best way to make variables local in a source'd bash script?

I have a bash script that generates a report on the progress of some long-running jobs on the machine. Basically, this parent script loops through a list of child scripts (calling them all with ...
1
vote
4answers
71 views

How to number a string in each line of a file

Given file.txt that looks like this: line_ some text line_ some text line_ some text How can I number the lines like this with Bash: line_1 some text line_2 some text line_3 some text Here is my ...
1
vote
2answers
23 views

How to pass an argument from a bash script to 'x-terminal-emulator -e bash -c'?

Let's say I've got this script : x-terminal-emulator -e bash -c 'echo hello > ~/text' I call it foo.sh and make it executable. If I execute this script I'll have a text file in my home folder ...
1
vote
2answers
70 views

What's the most efficient way to log crontab shell script errors with error occurred time?

A common way to log crontab task errors looks like below: 1 */8 * * * sh /pseudo_path/test.sh 2>> my_err_log It's a concise command, but it can't record the error occurred time, and the path ...
0
votes
2answers
39 views

Variable expansion inside parenthesis and quotes

In the script below, I can't seem to make $var1 expand in the second statement. I've tried $var1, ${var1}, echo $var1 and '$var1'. It is inside a few sets of quotes and parenthesis which I guess is ...
3
votes
1answer
23 views

Bash script with conf file with unknown number of sets of variables

I am writing a bash script that has a configuration file. The configuration file will have sets of mode and mtu values. There can be zero or as many sets as the user defines. The bash script will ...
0
votes
0answers
38 views

Drawing a histogram from a bash command output

I have the following output from a miRNA Predictor: Read Sequence:hsa-miR-576-3p MIMAT0004796 (22 nt) Read Sequence:gi|182396|gb|M74088.1|HUMFAPAPC Human APC gene mRNA, complete cds (8972 nt) ...
4
votes
1answer
71 views

How do I find a file name that's exactly 8 levels deep?

I'm using the 'find' command to search for files in a backup system. I want to find all file names containing a certain string (e.g. 'XYZ') that are exactly 8 levels deep. Is there a find syntax that ...
0
votes
1answer
41 views

Print the values from files

I have two files $TMP_RPT_FILE and $TMP_RPT_FILE1 . In $TMP_RPT_FILE - Meter readings come and $TMP_RPT_FILE1 - Meter Id come . I want if any data came in any of those files it should print . I tried ...
0
votes
0answers
35 views

How to scan for wireless networks fast

I have written a script which scans for wifi networks with iw dev wlan0 scan and put the SSIDs in a file. Is there a similar tool wich works a bit faster?
0
votes
0answers
33 views

Detect when sdcard removed

I'm working with a small Arm board (Emtrion) running Debian Linux. Emtrion has provided an sdcard image that can update the boards flash. I would like to extend the simple update script, so that when ...
2
votes
2answers
81 views

Bash script function that changes the value of a variable

I'd like to make a function for a BASH script that changes the value of one of its arguments, that is a variable. The function that I did is: chck_rgx () { # Checks that the given name for a ...
0
votes
0answers
26 views

Korn Shell script to check if a folder and file exists and print that to a csv file

i am new to unix. I want a Korn Shell script to check if a folder and file exists and print that to a csv file Regards gani
2
votes
1answer
35 views

Dynamic Variable in KornShell Script

This KornShell Script (ksh): envir=Dev eval "${envir}foo=bar" echo "$Devfoo" Output: bar But I will not know what value is assigned to envir variable. So I want to do something like this where ...
4
votes
6answers
374 views

Grep the text which matches with a pattern

I was looking for a command which will print the selected portion of a line which matches the conditions. Eg, my text line is like this: p1=X||p2=Y||p3=X||p4=X||p5=X||p6=Y||p7=X I want to print ...
1
vote
1answer
68 views

Convert multilines to single line with SED

I need additional help, based on similar question I have located here: Convert multilines to single line Current SED example (sed -e'y/)},={/(((((/' \ -e's/-\([^(I]*\)[^0-9]*\([0-9]*\)[( ]*/- \2 ...
1
vote
3answers
137 views

How to pass variables to awk command with conditions?

I have a while loop which reads data from a file with city names: city_name: COIMBATORE MADURAI PONDICHERRY SALEM TRIPUR TIRUCHI TIRUNELVELI TUTUCORIN VELLORE and using an awk command within the ...
1
vote
2answers
257 views

What does [[ -t 1 ]] do?

To my understanding, the script below runs if the user is not root by comparing $EUID and 0. Then, it uses [[ -t 1 ]] to decide if the script is running in a terminal or not. If it is, it will use ...
-1
votes
1answer
68 views

Storing command output into a Variable in Bash

#!/bin/bash NEW_TEXT="if failed Send to Karn Kumarl" OLD_FILE="$(awk '{print $1}' RMANJOBS | while read JB;do autorep -j $JB -q;done | egrep "^/|^insert_job|^description" | sed '0~3 a\\')" ...