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

learn more… | top users | synonyms (2)

0
votes
0answers
8 views

How to create a script to run several scripts on different servers

I need to automate the execution of several scripts, and I'm writing a script. The scripts have to run concurrently because they are part of a benchmarking suite. I'm trying to execute 6 different ...
1
vote
0answers
9 views

Programatically / dynamically adjust SSH session port forwards

I have a workflow where I am trying to do the following: For a given existing SSH session, access the remote machinne and perform a process from which a port is returned (e.g. a remote daemon has ...
0
votes
2answers
23 views

File mapping reference from another file

File1.txt age name city 23 ABC delhi 25 xyz mumbai 12 xxx pune 21 YYY delhi File2.txt city pincode delhi 001 mumabi 002 pune 003 I need to replace city column in file1 with pincode ...
0
votes
2answers
28 views

how to extract path from file location using shell

how to extract path location from below given string. /opt/oracle/app/oracle/product/12.1.0/bin/tnslsnr expected output. /opt/oracle/app/oracle/product/12.1.0/bin (or) ...
0
votes
0answers
18 views

Wifi configuration failed while using shell script

I am trying to configure wireless network in a Linux machine using a shell script. In this shell script, first I am scanning for all nearby available wifi networks with respective details. After that ...
1
vote
4answers
72 views

Please help me how to delete the files in one folder which are more than 60 days old in UNIX

I know how to delete the files the files which are more than 60 days old by modification time, but I want to delete files based on a timestamp in the file name. For example, I have the below files ...
1
vote
5answers
43 views

find the max value of column 1 and print respective record from column 2 from file

How to find the max value from the column 1 and echo the respective path location from a file which contains n number of records. $ cat version.log 112030 /opt/oracle/app/oracle/product/11.2.0 ...
1
vote
1answer
35 views

How to find out the biggest number in many documents that contains different numbers

For example, there are some temperature data at those folders in different time. temps.txt contains the temperature number. So how can I use bash script to find out the maximum temperature? (the ...
0
votes
1answer
29 views

script - recursively iterate over newline delimited list using a given depth range [on hold]

Years ago I encrypted a disk back-up image with an extremely long passphrase which I can no longer recall. However the passphrase is comprised of a number of smaller phrases which I do recall. ...
1
vote
2answers
47 views

How to get 2 different outcomes from 1 file in unix?

So I'm trying to make a dungeon and I want to have 2 different responses when I enter the one room but I thats as far as I can get. How do I get 2 different outcomes from 1 file? So when you open a ...
0
votes
0answers
47 views

Cut specific characters into columns [on hold]

I have a file as below: 2043630001007316220473533459926000000000003960CANDOVER INVEST S LONGHURST EXP 143292043630001007304400000000000000000000000000000 ...
0
votes
1answer
47 views

bash script programming question

Why the stomach of cat has ": No such file or directory" ? Help me please! #! /bin/bash if [ $# != 1 ] ; then echo wrong arg,please input one arg exit 1; fi if grep '^[[:digit:]]*$' ...
2
votes
1answer
17 views

Tool to add hierarchical structure to output, similar to tree

Is there a tool that is similar to tree which could be used in conjunction with echo? I want to easily prepend hierarchical structure to output. I know I could write it, but if a solution ("do one ...
1
vote
3answers
50 views

How to test for unknown commands in shell script?

I would like to know, if there is a way to go through a shell script and getting a warning for every command, that is unknown. I know bash -n for syntax checking, but it doesn't tell me, if there are ...
0
votes
1answer
19 views

Confusion about basic bashscript loop - until/done [duplicate]

I have a bash script I'm working on to help with an installer. why doesn't this work? function fn_myFunc(){ local MYVAR=0 until ["$MYVAR" -ne 0]; do whiptail --yesno ...
3
votes
3answers
216 views

Press any key to pause shell script, press again to resume

I've written a shell script for testing an API that copies files and echoes its progress after each one. There is a two second sleep between each copy, so I would like to add the ability to press ...
-2
votes
0answers
32 views

making a delete script and a restore script

I'm looking to create two scripts; one to "delete" a script, and one to "restore" I need "del " where this will move the file located at to the dustbin directory in a way that will allow it to be ...
-1
votes
1answer
19 views

how to replace a specific pattern from all files [duplicate]

suppose I want to replace abc with xyz in all files in a directory. How do I write a script for this ?
1
vote
0answers
44 views

Update process name in shell, is it possible?

In C/C++ it is in general possible to do strcpy(argv[0], "new process name"). It's a hack used in malicous software to hide real process name. Is such operation possible via shell? What I want to do ...
1
vote
0answers
24 views

trash and restore script - issue restoring

#!/bin/bash echo "Are you sure you want to move this file to the Recycle Bin?" "(Yes/No)" read ans case "$ans" in Yes) echo "$(readlink -f $1)" >> "$HOME/TrashLog" && mv "$1" ...
0
votes
1answer
23 views

check status process output

I wanted to understand how to create a script sh that allows me to see if an additional script functions correctly. For now this is the script that I created. if /run.sh status echo "$SERVICEXE ...
1
vote
1answer
17 views

'hhighlighter' wrapper script saying command not found

I have gotten the wrapper script 'hhighlighter' from https://github.com/paoloantinori/hhighlighter which colors anything you want in stdout. I followed the instructions about installing ack-grep, ...
2
votes
1answer
23 views

Command Line Macros in Comments using SLURM

In my opinion, comments are comments are comments. They should NEVER change program state. Sadly, the people over at SLURM disagree. SLURM requires the following syntax (or something similar) to ...
0
votes
3answers
66 views

How to print only certain characters?

I have to translate the permissions of a file this way: r ► c w ► s x ► e Then, I must extract the group of characters which are related to owner group. Last step is to print that group of ...
0
votes
3answers
42 views

Find the parent of a process

I am trying to write a script to help with computer security. I am trying to look for open ports, find the PID, and find what called it. I have it working, where my output looks something like this: ...
1
vote
3answers
177 views

Is there a difference between “a=b” & “a=$b”?

I came across two Unix scripts in my textbook. In one of them they implemented a=$b (in the form of max=$a) and in the other a=b (in the form of number=num). Question Are these the same thing or is ...
0
votes
2answers
54 views

Help in starting learning bash script [on hold]

I have just started analyzing sequencing data using Linux. I have created a pipeline for variant calling that includes eight commands or maybe more. I need to paste every command one by one and wait. ...
0
votes
1answer
53 views

Editing lines in a file using a bash script?

I am creating a bash script that installed VSFTPD / FTP. After the installation some configuration is required in the "/etc/vsftpd/vsftpd.conf" file. This includes making sure the following lines are ...
4
votes
7answers
439 views

Command line tool to “cat” pairwise expansion of all rows in a file

Suppose I have a file (call it sample.txt) that looks like this: Row1,10 Row2,20 Row3,30 Row4,40 I want to be able to work on a stream from this file that is essentially the pairwise combination of ...
1
vote
2answers
67 views

Sort files according to their extensions

I have made a script that will sort files according to their extension and place them in the proper folder. For example, place abc.jpg in the directory jpg. #!/bin/bash #this script sorts files ...
0
votes
2answers
25 views

How do run MYSQL scripts from a shell script with bash variables?

Im making a script where I connect to a database, look for a value and then if that value returned something then I will do something else. ip=$("variable is defined here") Then I connect to the ...
0
votes
0answers
48 views

(Solved) Bash Graphical uninstaller using a tool to make graphical my script [on hold]

I have a problem with logic on this part of my script, I can't see my fault. . Basically the script must be do the follow: Well when i click "Yes" its "Yes" when i click "No" , its "Yes" , i dont ...
0
votes
0answers
17 views

Bypassing the security message in Debian 7 when creating a bash script? [duplicate]

I've created a bash script which involves the installation / update of wget. As a result there is also a message from Debian showing the following: wget (1.13.4-3+deb7u2) stable-security; ...
1
vote
1answer
35 views

Ubuntu runuser command?

I am creating a bash script that requires to run commands as a specific user. As a result I am using the command: runuser I have tested this script and it works perfectly in Ubuntu Server 14.10. ...
0
votes
2answers
45 views

Percent signs and environment variable in a shell script

While troubleshooting an issue, I came across these entries given below in one of the shell scripts used by our application. This was written by someone who no longer works in the company and I am ...
4
votes
5answers
167 views

Calling multiple bash scripts and running them in parallel, not in sequence

Suppose that I have three (or more) bash scripts: script1.sh, script2.sh, and script3.sh. I would like to call all three of these scripts and run them in parallel. One way to do this is to just ...
1
vote
2answers
41 views

Why double ampersand chained conditions runs in background together the last one?

I have some conditions for some background job to run: condition-command && condition-command && background-job & The problem is: I want the conditions to block until the job ...
0
votes
3answers
55 views

Group by and sum in shell script without awk

I have a file like: $ cat input.csv 201,100 201,300 300,100 300,500 100,400 I want to add the values in column 2 which has same value in column 1. Expected output is as follows: $ cat output.csv ...
1
vote
2answers
38 views

disk space by individual user

I have around 50 user folder under etc/main/ folder. Now i want to get 10 large space user folder detail. Note: I don't want sub-folder of each user..I am using Ksh script. Example: /etc/main$ ...
0
votes
0answers
9 views

Running a script with elevated privileges [duplicate]

I need to find a way to run a script with elevated privileges but without compromising security. One suggested that i should use setuid but i don't think that is an option since it can cause serious ...
2
votes
2answers
116 views

Negative arguments to head / tail

Variants of this question have certainly been asked several times in different places, but I am trying to remove the last M lines from a file without luck. The second most voted answer in this ...
0
votes
1answer
56 views

sh script cannot run process

I have fairly simple sh script that checks if process is running, if not then start it. My problem is that sh script cant start the program for some reason... Here's my script: #!/bin/sh if ps x ...
0
votes
1answer
32 views

How to Trim below highlighted lines from Shell output

How to Trim below highlighted lines from Shell output. Source shell program is below the output. $ ./checkhome.sh The Oracle base remains unchanged with value /opt/oracle Connecting ...
2
votes
3answers
211 views

Bash File existence test is always true

I have the following lines of bash script to test whether a file exists: MYAPPPATH=$(find $APPDIR -iname myapp* -print) if [ -e $MYAPPPATH ] then echo "File exists" fi However when file ...
0
votes
1answer
11 views

How to script with systemd-cgtop?

The manpage for systemd-cgtop says that if there is no attached tty it will do one iteration and then print it out, saying that this would be useful in scripts. However when I try to do this from a ...
3
votes
1answer
43 views

Split input file into X parts of size total lines / X

Currently, my bash script splits by number of lines. However, I'd like to split a file into X pieces, each of those having total lines equal to the file length divided by X. The script is run as ...
1
vote
0answers
41 views

Cron can't access my home directory when I'm logged out

I have quite a strange problem using cron. I distilled it thus far: I created following simple bash script in /home/user1/cron_dir/cron.sh: #!/bin/bash echo "Success" As user1 I created following ...
2
votes
2answers
58 views

Inputting user input automatically through bash script? [duplicate]

I am creating a bash script which creates a user and sets a password. When the command "passwd user" is run it requires the user to enter a password and stops my script. Is there any way to fulfill ...
1
vote
1answer
59 views

Sh Script using ftp to put a list of files

So my Script looks something like this: #... files="$(find $line/processed/* 2>/dev/null)" #2>/dev/null used for error output suppression if [[ ! -z "$files" ]] then ...
1
vote
1answer
180 views

How to get owner and full path of 50 large size file across all users?

Below command list top 50 files regardless of subfolders. $ls -lR /root/home | sort +4 -5nr | head -50 Current Result: -rw-r--r-- 1 john dpst 192954384 Nov 7 07:36 filenxx1.gz ...