Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).
0
votes
1answer
11 views
Scp files to multiple server simountaneously
I have file called server.txt
Suppose it has below servers , there could be more servers
server1
server2
server3
server4
how can I copy file (file.txt on all servers using scp command) at /tmp/ ...
0
votes
2answers
11 views
Why isn't my .bashrc file being read from .profile
in my .profile file I have the line:
# source bashrc if it exists
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
to make sure that my .bashrc file is sourced if it exists. I also have a set up ...
0
votes
0answers
7 views
tcp socket forwarding from multiple sequential clients to a single persistent socket connection to server
I have three programs (A, B, and C). Program C has a tcp socket server waiting for connections on a particular port. Normally program A opens a socket connection to program C, sends it data, then ...
1
vote
1answer
19 views
How to substitute a multi-length word consisting digits and letters in a specific format?
I have a file as following which I want to change all of the code with the following format : n{,3}L{,2}n{,5} --> n= [0-9] any number and L [a-zA-Z] any letter either capital or not
What I expect ...
-1
votes
2answers
42 views
How to loop a command through a file column values?
I have a simple command like this
grep 'X' results.dat | awk '{print $NF}' > Y.dat
I want to loop this command taking the Xs from column 1 and the corresponding Ys from column 2 of the same ...
0
votes
1answer
21 views
Can I make curl or wget restart if disconnected?
I'd like to download a file through curl - the problem is that my connection is very slow, and by unknown means, stops receiving data after ~180 kilobytes.
Unless there's a better method to fix it, I'...
0
votes
1answer
25 views
Open new gnome terminal window with same directory as previous window
I'm running Awesome WM on latest Arch Linux and use Gnome Terminal as my terminal with Bash shell. I've managed to get this working, but I wonder if any form of improvement is possible to my ...
0
votes
3answers
47 views
Parallel Python scripts on a remote machine
Similar to this thread, I have a remote machine with 8 cores that I want to use for running scripts in parallel (1 script per core at a time).
However, I don't have multiple bash scripts but a single ...
0
votes
1answer
12 views
Change variable of parent scope from inside a function in .zshrc [duplicate]
I have this function in my .zshrc:
activated=false
function test_toggle() {
if [ $activated=false ]; then
echo "WAS FALSE"
activated=true
else
echo "WAS TRUE"
activated=false
...
0
votes
0answers
44 views
Password generator with user inputs bash script [on hold]
I am new to bash scripting and i wanted to make a bash script that will generate a password for a user.
The user must enter his/her name and the url of the site.
And the script will generate a ...
0
votes
1answer
17 views
Creating alert notification if process stops touching file
I have set up a very simple script so that I can test whether a process is running or not and if so then it will touch a file and everything will be fine. However if process is not running and file ...
0
votes
1answer
23 views
Count amount of files/directories in SELECTED directory
I'm trying to make a script that counts files/directories in a specific directory but I have a problem. Here's the script that works for a current directory (count.sh):
ARG3=${1:-d} #default value - ...
2
votes
1answer
52 views
How do I generate a script with an inverse action
I have an interactive script which sorts and processes a variety of filetypes from an unsorted folder into newly created directories.
I was wondering how I could write a small script or modify the ...
2
votes
2answers
50 views
Need help in bash script to send an email in single command line
I need a help to write a bash script to send an email when local host connection is refused and when the connection is open, it should not write an email. For example:
netcat -z localhost 8287
if [ $?...
-6
votes
1answer
24 views
Using shell script i want to give space to the starting of every line of a file [on hold]
i want to write a shell script and in that shell script i want to give space to the starting of every line of a file like, 1st line 1 space, 2nd line 2 sapce, 3rd line 3 space, 4th line 4 space......
...
0
votes
0answers
22 views
Executing matlab from a script upon double click, just like launching windows app from an icon
I am running Suse linux,
NAME="SLED"
VERSION="12-SP2"
VERSION_ID="12.2"
PRETTY_NAME="SUSE Linux Enterprise Desktop 12 SP2"
ID="sled"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sled:12:sp2"
I am writing ...
1
vote
1answer
39 views
How to use awk to correct and unify a corrupted file with multiple columns and lines?
I have a CSV formatted multi lines file with 5 columns (fields). I need to unify and corrected the corrupted first column which has lots of different formats of the code I need to unify. The complete ...
1
vote
1answer
18 views
How can I get a count of the frequency of lines among many files?
I have many (i.e. >> 2) text files. These files are all mostly similar but have some small differences between them. I would like to find the lines that most commonly appear among these files. For ...
1
vote
2answers
38 views
Store output in memory for writing later on disk
I have the following script which I use to log the CPU frequency. As mentioned in the script I store temporarily the output in the file temp.txt and then read it and copy it to the main file with the ...
0
votes
0answers
71 views
How to move 1.jpg, 3.jpg, … to 1.jpg, 2.jpg, …?
Assume you have a list of files where are gaps in filenames: 1.jpg, 3.jpg, 4.jpg, 7.jpg, but you would you like move them to an increasing order by one: 1.jpg, 2.jpg, 3.jpg, 4.jpg, ...
I think AWK ...
-5
votes
0answers
21 views
Linux addition and subtraction scripting writing [on hold]
how do I write a script to accept input or number and perform basic addition or subtraction and display as output?
-6
votes
0answers
29 views
Unix/shellscript Code Outline [on hold]
Can you give me the outline for a code.
I want to count the number of girls and boys entering a exam hall. This counting i am planning to do through swipe machine.
Thanks & regards,
Sindhu
2
votes
1answer
50 views
How to download file by faking the request's IP address?
I'm trying to download a file using wget, but I've exceeded (without knowing there was a limit) the limit of downloaded bytes for my IP address, which means that I can't download anymore the files I ...
0
votes
3answers
60 views
rm command in bash script does not work with variable
I am doing a bash script to create a back-up of my mysql databases.
Actually, I would like to delete the old ones.
So, I create my script with variable for maintability.
The whole script is actually ...
-6
votes
0answers
40 views
Script to find duplicates files for Linux [on hold]
How do I write a script that:
will analyse a directory of files
detect duplicates
write a file log.txt with a report of what files are duplicated with each other.
So log.txt should contain:
...
4
votes
3answers
381 views
Unable to assign output of nested commands to variable in bash
I was trying to assign below command(which choose the random line from file) to a variable, but not working.
givinv@87-109:~$ head -$((${RANDOM} % `wc -l < file` + 1)) file | tail -1
cower
givinv@...
0
votes
0answers
11 views
How are progress bars programmed in Conky and how can I apply this in my own custom one? [migrated]
I'm trying to customize my progress bars in Conky (battery_bar, fs_bar...) in order to have a layout other than the default one, which looks like:
Following this answer I managed to create a ...
0
votes
1answer
46 views
Exit the terminal and execute a command.
I want to exit the current terminal and execute a command. Is it possible to do?
PS:: Assume that I have made a loop while true; do bash;done
0
votes
2answers
36 views
Checking duplicate value in specific column in csv file with pipe seperated
Hi I have a csv file with data more than l lakhs and seperated by pipe it look like
2|dfdf|er34Sr|afe|&*&|djhgjdsf|jhfgdhj12|dse|dsR|fcdf|erer|ddff|vcdf||||||
3||||dfrg||DFgfg||FDGRFG|FGB|FG|...
0
votes
1answer
40 views
ssh execute remote script
I've an application on my machine that is working with a remote one. Before I'm able to use this app, I need to run some commands on the remote one. Here for I've created an script named startUpRun.sh....
0
votes
1answer
28 views
How to surround xarg's inputs with more arguments?
I'm trying to somehow use xargs so a program whose outputs are the lines
<ARG1>
<ARG2>
...
<ARGN>
will cause the execution of the following command:
command
<...
1
vote
1answer
30 views
wget not stopping
When I try to download pages with wget -r using a for loop it works fine but when I try it with -e robots=off it does not stop to that limit which I set for "for" loop, here is my code
#!/bin/bash
...
1
vote
3answers
30 views
How to remove directories in the correct order so that empty ones are removed?
I have a list of files & directories in a file in some order, and I want to write a script that removes them.
Directories are only supposed to be removed if all of their descendents will also be ...
-1
votes
0answers
24 views
How to recursively add .txt extension to all files in a series of directories [duplicate]
I have a bash script I am trying to modify. I am trying to cycle through all files in a folder and series of subdirectories, and adding a .txt extension to all files.
These files have no existing ...
-6
votes
0answers
23 views
After I install my backtrack [on hold]
After I install my backtrack when the back-up systems that do not put it off?
What drives Baydnsb after I installed? Please help me.
Thank
What should I install drive. For Linux backtrack r3
and
...
0
votes
1answer
25 views
How to export an environment variable from .sh file in zsh? [duplicate]
I have the following shell script
TEST=/foopath
export TEST
It is in a file called test.sh and on which I ran chmod +x test.sh
When I run ./test.sh I expect that I can then execute echo $TEST and ...
3
votes
1answer
33 views
Remove duplicate lines from multiple files in a folder: Check only files within a range
I had a question about removing duplicate lines in multiple files and was provided with a useful script here: Remove duplicate lines from multiple json files while preserving file structure.
The ...
3
votes
1answer
45 views
How can I secure these two scripts used in SSH authorized_keys further?
itunes.sh:
#!/bin/sh
set -f
set -- $SSH_ORIGINAL_COMMAND
case "$1" in
/home/dimm0k/progs/scripts/*)
;;
*)
exit 1
esac
command="${1#/home/dimm0k/progs/scripts/}"
shift
case "$command" ...
0
votes
2answers
61 views
How to check if string contains a substring in dash or ash?
Here is what I am tring:
#!/bin/sh
contains() {
if $(echo $1 | grep -c $2) ; then
echo "0" # contains
else
echo "1" # not contains
fi
}
myString=$1
mySubsting=$2
...
0
votes
0answers
11 views
ZSH mapfile, how can I get the bash behaviour? [duplicate]
Both bash and zsh support reading a file into an array, I'm used to the bash's way and am appalled by the zsh's behaviour: zsh starts the array from index 1! That's not the unix way.
Here is an ...
0
votes
1answer
57 views
Moving files into specific directories based on filetypes
I am having a bit of bother with a control flow statement for a small interactive script I have which sorts and processes unsorted files from a desktop folder.
The script takes in a series of ...
0
votes
2answers
29 views
Getting access to incrementing extension of file (as a integer variable) [duplicate]
I'm trying to code a simple script that uses sed to basic find&replace functionality.
I want to have original file untouched and have results in new files called "file.n" (n is being incremented).
...
-3
votes
0answers
28 views
My site notifice me [closed]
Can you help me If there any way to notifies me by email when my web site is unresponsive using shell script ?
I try to use manuy script but it dosn't work
2
votes
2answers
116 views
Read file line by line and put in other string
I want to read file line by line and put its content to other string in specific place. I have created the below script but unable to put file content in that string.
File: cat /testing/spamword
spy
...
1
vote
2answers
39 views
Bash can't run command from script: mkdir command not found [closed]
I have separate scripts for tasks in bash. Here is the broken one:
#!/bin/bash
PATH=/home/name/
mkdir $PATH
cd $PATH && echo "done."
exit 0
Today it broke and first time it simply didn't ...
2
votes
2answers
71 views
list subdirectory with some naming conversion
I want to write a script that will run a certain commands on my subdirectories with names containging or rather end with some strings, say, *-nom1, *-nom2, *-nom3. i.e.
for dir in $(subs)
do
// do ...
1
vote
0answers
58 views
`Unhandled Exception: System.ArgumentNullException: Value cannot be null.` error while running `dotnet run` using a startup script
I'm trying to run a dotnet app using dotnet run --configuration Release at system server Startup/Reboot. I'm using a init.d script to acheive the same.
My startup script, located at /etc/init.d/...
1
vote
1answer
18 views
Shellscript curl gives error
I am trying to create a little shellscript using curl.
This is the script(i need to hide the username,url & Co.)
for i in `cat cain.txt`
do
uuid=$(curl -X POST -H "ACCEPT-LANGUAGE:en" -H "...
1
vote
0answers
27 views
How to update the columns in run time in temporary table?
I have tried to update some columns in below text files and make its as a new updated text file.
Delivery:
delivery_id count_reqd order_date prod_id qty_delivered
1 30 ...
0
votes
1answer
18 views
shell for compressing files in batch
I have a server where there are more than 5.4 million files with random nomenclatures. Now I want to write a shell script to compress those files into 1000 gz files of 5400 files in each. I also want ...