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

learn more… | top users | synonyms (2)

1
vote
2answers
23 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 ...
0
votes
0answers
6 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/...
0
votes
1answer
14 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 "...
0
votes
1answer
16 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 ...
1
vote
1answer
17 views

Clean way to bring back background process to foreground in shell script

As an example: I have working shell script which starts up weblogic (which will continue to run) and then do deployment At the end I bring background process back to foreground, so that shell script ...
1
vote
2answers
42 views

Sync same directories between two linux servers

There are two RHEL 7.2 linux servers located in different places. Both have same directory structure. Requirement is to keep certain directories of both servers in sync, i.e any modification in ...
1
vote
2answers
51 views

Bash script performance

In a bash script, some integers in a range are generated, concatenated with fixed strings, and printed on a file. OS is Ubuntu 14.04 and bash version is 4.3.11(1)-release. The strings (and so the ...
-2
votes
0answers
22 views

check validity of input username [on hold]

I want to write a bash script that read an input and then check whether the input is equal to any users of ubuntu then login else again ask you to enter an input. function f{ echo"please enter a ...
0
votes
3answers
35 views

bash: clear string between two positions

I need to clear string in terminal between two positions (not the beginning or end of line). For example, delete all starting from tput cup 5 10 and till tput cup 5 69. One line. Yes, it's possible ...
0
votes
0answers
4 views

sftp proxy setup to connect to remote server which is not in the same network

I'm new to bee to the unix world, I have to connect to remote server which is not in the same network I'm working. I have the username, ip address and password for the server. i tried this command to ...
1
vote
1answer
21 views

Sort the directories and files in each directory in ascending order and export data to csv

I have 30 directories i have more than 300 text files in each, all text files in each directory have same naming format regional_vol_GM1.txt regional_vol_GM2.txt regional_vol_GM*.txt I would like ...
-4
votes
0answers
14 views

How to get and kill the process related to project [on hold]

#!/bin/sh processName=$1 processKilled=false OS=`uname` export OS case $OS in Darwin) processIds=`ps -ec | awk "/$processName/ "'{print $1}'` ;; *) processorType=`uname -p` export ...
39
votes
2answers
4k views

Why is pattern “command || true” useful?

I am currently exploring Debian packages, and I have been reading some code samples. And on every line in, for example, the postinst script is a pattern. some command || true another command || true ...
-3
votes
1answer
21 views

I want a script which will delete all the files in the directory except the last days files [on hold]

ex: files come on 9th and 10th and 11th, we do not know the number of files coming each day. i want to just keep the files of 11th and delete the ones of 9th and 10th
0
votes
1answer
30 views

bash one-liner: set variable to output of command or to default value if output is empty

I know that in Bash you can use the syntax editor=${new_editor:-/usr/bin/vi} which will set editor to new_editor if the variable new_editor is not empty and to /usr/bin/vi otherwise. Is it possible ...
0
votes
0answers
31 views

Unmonting a filesystem without crashing kernel

I've mounted a file system 32 bit over fedora 24 64bit. The problem comes when I unmount it. my pc doesn't accept any command and I must give shm permission with chmod 1777 /dev/shm to restart browser ...
0
votes
1answer
28 views

Compare length of string AND if string contains numbers [on hold]

I'm trying to make a shell script where the user inputs a date and then the script is supposed to check to see if the date is in the valid format, mm/dd/yyyy; all numbers. I'm able to use substrings ...
0
votes
2answers
28 views

How to remove the lines that have empty fields?

I have a CSV file with multiple columns, comma "," separated and numbers of lines. some lines have empty one or two fields "Columns". How i can identify in a separate file and/or remove those line ...
-1
votes
0answers
30 views

for loop or while loop to read the fields of a file

I have two files File_1 and File_2 (reference file). I have to compare the 1st digit of File_1's 2nd column to File_2's 1st column for tagging and count. I also have to sum up the 3rd column of file_1 ...
0
votes
0answers
20 views

gawk fieldwidth to pass as parameter [on hold]

I have questions here from gawk I have fixed width file which I am trying to conver into Csv comma delimiter. Unable pass as parameter or variable for fieldwidth options. Please let me know how to ...
2
votes
0answers
19 views

Reading the status of the screen

I used to read the status of rotation of my screen with this command in fedora 22: status=$(xrandr --verbose | grep LVDS1 | awk '{print $6}' and the output would be something like noraml or inverted ...
10
votes
4answers
860 views

How to get last part of http link in Bash?

I have an http link : http://www.test.com/abc/def/efg/file.jar and I want to save the last part file.jar to variable, so the output string is "file.jar". Condition: link can has different length ...
-4
votes
0answers
20 views

Fixed width to delimited file for more than 1000 columns

I have a fixed width file with more than 1000 columns. It needs to be converted to a delimited file along with column header with the delimiter as |(pipe symbol). Control file of excel type(.xlsx) ...
1
vote
1answer
42 views

How to execute a command inside a shell script without opening a new shell

I would like to execute commands inside a shell script and store in a variable, but it is opening a new shell which I do not want. Is there any way to correct this? Here is my script. #!/bin/bash V1=...
1
vote
0answers
17 views

Using a custom filter via script to reject inbound email

Background & Requirements I've found a number of reference docs and Q&A post relating to this topic but I've not been able to figure out a key area of the design. I would like to reject an ...
0
votes
1answer
59 views

cleaning output of a script so it's descending, gives package names and cleanly exists

I filed Is there a way to find patches which need testing from packages you have? and I was given a script which works - for source in $(dpkg-query --show -f '${source:Package}\n' | sort -u); do bts ...
3
votes
2answers
36 views

tailf output as script parameter

Why is it when I leave the following tailf running: tailf /var/log/z-way-server.log | grep --line-buffered device-info | gawk 'BEGIN { FS = "\"" } ; {print $4,"is",$8}' I get my desired output: Den ...
-1
votes
2answers
25 views

Copying files while maintaining file attributes

Say, if I want to copy /etc/bin to a folder while maintaining the file attributes as well as parent directories. [The target folder should not just contain bin folder but /etc/bin.] Is the possible ...
0
votes
1answer
19 views

Checking if software is installed in SSH session

I am trying to check whether a certain package is installed on remote machine in bash script. If I execute the following statement on the machine itself the result is 1 (installed) in file check.txt, ...
1
vote
1answer
18 views

How I can find line(s) which the third columns is not digit/date?

I am trying to use awk command to find line(s) which the third columns is not digit/date? Suppose there is a file comma "," field separated, has three columns and as code "," measure "," dd/mm/yyyy, ...
-1
votes
1answer
35 views

Append value as parameter to shell script

I found the value of a response (curl) with sed and now i need some help to take the value that i printed in a file and to use it in another substring in the same .sh script This is the response of ...
0
votes
2answers
54 views

Extract UUID value from JSON returned from HTTP reply

I am trying to make a little script in shellscript that takes one serviceUuid from a response and use it. I just print the server response on a file called final.txt Now i need to extract the value ...
1
vote
2answers
68 views

Syntax error: “(” unexpected (expecting word) — in my bash script

I have a bash script: #!/bin/bash VAR1="var1" VAR2="var2" VAR3="var3" cat ${VAR1} \ <(echo -e '<something>') \ # <--------- here's the error ${VAR2}/...
1
vote
1answer
22 views

How to check creation of two new files in bash and perform action?

I have written a script which will check if a single new file is created and perform the action. However I want to perform that action if 'two' new files are created. Below is the script : old_count=...
1
vote
1answer
26 views

Save temporary history via script

I want to save the temporary history to a file via script. In the bash it works like that: history -a /tmp/tmp_history But if I add this line to my script, the tmp_history is empty. I use it like ...
-1
votes
1answer
57 views

How to sort and join files in linux with huge data and print blank values for the values which are not found

Consider the below files : file1: 1 2 3 4 file2: 2 3 6 9 expected output: 1 NULL 2 2 3 3 4 NULL NULL 6 NULL 9 I have tried paste file1 file2 | sed 's/\t/\0\t/g' | column -s $'\t' -t ...
0
votes
2answers
32 views

Count the number of processes and send a email to multiple people if it exceeds certain limit

As part of smooth functioning on my application I want to check a count of a particular process and send a email to multiple people if it exceeds certain limit.I have written script for counting ...
1
vote
2answers
27 views

Finding last character of base file name

Say there are different files, script.sh text.txt pic_1.png or files with no extension - 'hello'. How can you extract the last character of base file name? ie, script. sh - t text.txt - t pic_1....
2
votes
2answers
32 views

Applying bash function to each file in subfolder recursively

I am trying to write a script that will apply a bash function for each file in a directory recursively. For example if the directory tests had all my files and sub-directories in it, the script find ...
0
votes
0answers
11 views

How to create a local apt repository for Hadoop, HBase installation?

I want to create a apt repository for Hadoop and HBase installation, over my private LAN, so that people in my LAN can just to do apt-get install hadoop and install hadoop cluster. There are ways ...
-4
votes
0answers
37 views

while loop issue [closed]

i am using while loop to loop through lines a file and for each line it will start another script. Example, in list file data is as follows: NEWYORK CHICAGO NEWJERSEY WASHINGTON SFO it has to loop ...
0
votes
0answers
17 views

lock bash script to prevent parallel running from within the script itself?

I am aware of using flock and solo (not sure the difference though) when running from a cron job. However, is it possible to prevent parallel running from within the script itself?
1
vote
0answers
34 views

Have output and input in the same window in a Bash script

I'm trying to make a chat program in Bash. I've stumbled into a problem though: I have no idea how to have the input and output on the same screen. What I mean by this is something like the Minecraft ...
1
vote
1answer
38 views

Ubuntu terminal closes after running the script

This is a .sh file which the Ubuntu terminal runs then quits immediately. What is wrong with my script? I don't know what my problem is – why the terminal closes after running the script and does not ...
1
vote
1answer
43 views

Escape spaces in bash script not working [closed]

Nothing I've tried works. Look at the grep to array lines in the script below. Escaping seems to do nothing. But if I make a statically assigned array It's fine. Such as: files=(somefile.txt some\ ...
-1
votes
0answers
43 views

Manipulate output from two loops

I have two queries and I want to run them simultaneously in the loops. Basically, both queries give outputs of domain names and I want to remove a domain name from the output completely if the ...
1
vote
1answer
14 views

Bash script fails in DD-wrt

I have the following bash script running at startup on my WRT1900ac linksys: USER="admin" PASS="passhere" PROTOCOL="http" ROUTER_IP="192.168.1.1" # Port to connect to which will provide the JSON ...
1
vote
2answers
18 views

Valid characters in here doc tag

What characters are valid in a here doc tag? cat << 'what_characters_can_be_used_here' what_characters_can_be_used_here I ask, because I want a string that is very unlikely. Thus, I want to ...
3
votes
0answers
16 views

Open Konsole sessions (tabs) in two distict windows

I have a script that opens Konsole sessions for me to work with, it looks like: konsole --profile $1 --new-tab -p tabtitle="k1" -e ./jpax_remote.sh cc1 konsole --profile $1 --new-tab -p tabtitle="k2" ...