A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

-1
votes
2answers
56 views

Linux Bash Scripting Issue with Wildcard

I'm having issues with what I imagine should be a simple bash command I'm basically just trying to loop through a bunch of files and get there names `ls ./*.sql` # list all files ...
0
votes
2answers
44 views

How to scrape multiple IP's and add in a script as a variable?

I am trying to add in my script an awk statement or a: if; else; then if eth0:4 is a match then put in eth0:4 IP How would you get the IP in your script as a variable if you have multiple IP's ...
1
vote
1answer
57 views

Rsync Excludes Folders

I am running a rsync script and I want to exclude certain folders. I know with rsync you have to create a .txt file and add all the excludes in there but I am wondering is it possible to just have a ...
3
votes
0answers
32 views

End recording once silence is detected

I've been using something like this up to now: End sox recording once silence is detected But now I'd like for the audio source and recording mechanism to be separate. I can get the source as an ...
0
votes
1answer
42 views

Printing conclusion at the end of script

In this example code I have numbers in the file "list.txt" I wanted to create folders in a specific location "target" for every number in the file "list.txt". In order to do so I used for loop as the ...
1
vote
1answer
56 views

How to change bash script output when the script is running?

I have the following loop which counts from 0 till 99: #!/bin/bash for ((i=0;i<100;i++)); do echo $i sleep 1 done Is there a way to change the result of the output from terminal while ...
1
vote
1answer
61 views

VBox on headless server: install linux without RDP

I have script to setup headless machine on remote headless server, connected by ssh. It will create machine, attaches disk and archiso, and launches installation. Also, I have script to setup ...
1
vote
1answer
101 views

How to determine interface RUNNING state without ifconfig?

Some background: sometimes my wi-fi connection suddenly goes down so I type sudo ifconfig wlan0 and check for the word RUNNING. The corresponding line looks like: UP BROADCAST RUNNING MULTICAST ...
16
votes
4answers
621 views

How can I implement a circular flow of data among interconnected commands?

I know of two types how commands can be connected with each other: by using a Pipe (putting std-output into std-input of the next command). by using a Tee (splice the output into many ...
2
votes
1answer
65 views

Need to press enter to get prompt after executing udev script

I have set a simple udev rule for my Raspberry Pi (Debian) to automatically mount an USB HDD. It just runs a script which mounts all devices in /etc/fstab since it's the only one I have and I'm going ...
-1
votes
1answer
432 views

Syntax Error: unexpected end of file — Bash script [duplicate]

I am trying to create an spritz app! Everything was working fine, but since yesterday I keep getting this error: ./spritz: line 176: syntax error: unexpected end of file I have checked the script ...
0
votes
1answer
26 views

How I can change all symlink to the new path [duplicate]

Please, I want to change the symlink to the new path My symlink's in this form lrwxrwxrwx. 1 s01 s01 56 Mar 22 13:17 zmjppcxlpq2m.png -> /home/s01/public_html/cgi-bin/uploads/00029/zmjppcxlpq2m ...
2
votes
1answer
77 views

what are practical uses of stdbuf or nohup?

I have to finish a writeup of a few coreutils commands for a course at the moment, and I can't think of a starting point for a small practical code example that demonstrates the potential uses of ...
2
votes
1answer
82 views

bash: how to save state on prompt evaluation [duplicate]

I want to put duration of last running command in command prompt, f.ex: user@host$ sleep 360 6m user@host$ Also, I want duration to not show up if it is less than some minimum threshold (say 30 ...
0
votes
0answers
75 views

grep command with pipes, how to implement in script?

I'm new to expect scripting and trying to get below script to work. The script logs in to a server and reads a config file ($val in the script) for the values of "cps" and then presents a total ...
0
votes
0answers
19 views

DHCP server easy switch

i have a server, running Centos, that bring reserved DHCP for mac to 5 computers, but they have diferentes ip depending on some external parameters, and i change manually everytime, and i want know ...
0
votes
1answer
49 views

User Input Bash Script

I am trying to make a Bash Script that has 4 choices and prompts the user to select an option. Each option corresponds to a Linux Command operation. Can someone give me a bash example on how could ...
0
votes
2answers
72 views

Adding 1 string to end of file, Even when ran multiple times to change MD5

I need to change the md5 of my files, Sometimes once, sometimes multiple times. A friend gave me this script to add a string to the end of the file but i think i may be adding it multiple times when i ...
1
vote
2answers
1k views

Conditional statement, “unary operator expected”

I am having a problem with an example script that is given in the textbook 'Unix and System Administration Handbook'. The script is below... I am receiving an error that states logscript: line 8: [: ...
0
votes
1answer
79 views

Systemd user specific service and timer

I have installed arch recently and added a few of my own services, for example the acpi_call commands and such. Now I want to create a systemd service that runs every 5 minutes and execute a script. ...
5
votes
6answers
196 views

Remove Same Column Values

I have a very big file and I want to remove if the column value is 9. Sample: My file value like this: 1 5 8 3 5 9 5 7 6 9 2 5 7 4 2 9 7 6 3 1 5 9 7 4 1 9 5 7 9 1 I want to delete any columns ...
0
votes
0answers
32 views

Script for auto-starting programs after restart

Is there any script or program to make all open programs auto start after the system restart? Like the one on the mac that gives you the option to reopen all programs after restart or shutdown
2
votes
2answers
509 views

How to delete old backups based on a date in file name?

I have a daily backups named like this: yyyymmddhhmm.zip // pattern 201503200100.zip // backup from 20. 3. 2015 1:00 I'm trying to create a script that deletes all backups older than 3 days. The ...
0
votes
0answers
45 views

Rancid for Dell Powerconnect 5524

I´m trying to back-up the configuration of a Dell Powerconnect 5524 switch using RANCID. The script I'm using is srancid. I've also tried with dell and dlrancid, none of them worked. Srancid works ...
0
votes
0answers
122 views

How to use “on commit” with isc-dhcp-server (IPV6)

I try to use the "on commit" trigger in isc-dhcp-server. I made prefix delegation, and I have problem with updadting routing table, so i want to use the isc dhcp triggers to manually update routing ...
0
votes
1answer
47 views

Script to Log Shutdowns and Reboots

I am trying to create a script that will run daily as a cronjob and log all shutdowns and reboots. I've come up with this, but the grep seems to be ignored, and the script results in the output of ...
1
vote
1answer
36 views

How to move directories based on the output of rhash (CRC32 check of .sfv) with bash/perl?

My idea, is to move the CRC-check OK folders (albums) into a lets say "complete+CRC_OK" folder with a script once per day in cron. I would need to put the rhash command in a loop with number of ...
2
votes
2answers
43 views

How to transform string with character codes into quoted form

I have a string like New\x20Folder. Special characters is represented by their codes. I'd like to transform the string into quoted form: "New Folder". The only available tools are bash and bunch of ...
2
votes
1answer
48 views

Updating config files within the script that references them?

I have no problem adding config files to a given script, but automatically updating them is another matter. In this instance I'm providing a few variables to a script, and I'd like the script to be ...
2
votes
2answers
68 views

vim: using a for-loop-iterator-variable in a search pattern

I am trying to use a for loop iterator variable in a vim search pattern to determine for a range of words how man times they occur in a file. What I do so far is: for i in range(1,40) | %s/SiTg//gn | ...
14
votes
4answers
1k views

How to retrieve IP addresses of possible ssh attackers?

I've just cat /var/log/auth.log log and see, that there are many | grep "Failed password for" records. However, there are two possible record types - for valid / invalid user. It complicates my ...
0
votes
2answers
41 views

Why is the suid bit having no effect on a shell or perl script? [duplicate]

As an experiment in playing with the suid bit, I tried writing a script to run apt-get update from a bash script, and then set the suid bit on it, so I could just run ~/update or something. apt-get ...
2
votes
1answer
162 views

Transform .csv into 3 columns and a row

Sample Input: id,Product1,Product2,Product3,Product4 1,0.1,0.3,0.8,0.7 2,0.6,0.7,0.5,0.9 I need output as : id,productname,product_val 1,Product1,0.1 1,Product2,0.3 1,Product3,0.8 1,Product4,0.7 ...
1
vote
2answers
25 views

Substituting file extensions on a variable

I'd like to do the following : create a .tex and directly show it after compilation with evince, ideally it would be like this: showpdf file.tex so I wrote #!/bin/sh pdflatex $1 && ...
3
votes
2answers
286 views

how to execute a bash command in a python script

How can I launch a bash command with multiple args (for example "sudo apt update") from a python script?
1
vote
2answers
55 views

How to copy only files in a specified directory to another folder

I'm trying to copy only the files from one directory (not including folders or any files in its subfolders) to another location using cp /media/d/folder1/* /home/userA/folder2/. It is copying the ...
3
votes
3answers
779 views

Switch user in a shell script without entering the password

I'm running a shell script using terminal from userA. In the middle of this shell script, I switch to userB user using su, but this asks me for the password of userB and I have to manually enter the ...
1
vote
4answers
164 views

bash division of numbers in text file

I have two numbers in test.txt file, I would like a way to divide the second number by the first number and assign the result to a variable or file in a bash script that I can use. I have used awk ...
1
vote
2answers
61 views

Need special validation for shell script

I want to create a bash script which will have lot of options while executing. # script.sh --dry-run --user <parameter1> --pass <parameter2> I heard about getopt option but looks like ...
1
vote
2answers
110 views

Capture errors in a SFTP script

I have a sub sh file which puts receives an input of local directory and path to the remote directory and sends the file to the remote directory. If the remote path is invalid the error cannot be ...
2
votes
1answer
86 views

Please explain the syntax

Can someone explain the syntax of the following commands? II know what they do but was having a hard time getting the syntax, find / -type f -exec grep -H 'text-to-find-here' {} \; cat access.log | ...
-1
votes
1answer
84 views

How to write a auto-completion bash script?

I want to run some functions (which I created in ./.bash_func) in terminal with some files located somewhere. When I type the function and hit Tab Tab I want to list the files located in ./scipts like ...
1
vote
4answers
74 views

Delete all files in a directory

I have a directory which includes some files and some folders containing other files. I'm trying to remove these files in the main directory without touching the folders or their contents. I'm using ...
2
votes
1answer
40 views

Copy files that partially matches another files in another location

I have a list of jpeg files in a directory like this (below is just a sample, like the structure is the same but this there are many fo0# sub-folders, not only fo01 and fo01, where each of these ...
2
votes
1answer
90 views

Remove newlines in file names

I have a PHP code that generates the file name on which wget will append its logs. I generated 2000+ files, but the problem is I am having trouble working with them because I had a mistake of putting ...
-2
votes
2answers
39 views

grep to get all the getters from a java file

I have a java file called Friends.java . There are 5 variables and each variable has its own getter. Assume that all the functions below follow standard java standard, i.e public methodName(){ //Some ...
2
votes
2answers
68 views

Is shell parent of all the processes in linux

I have been trying to understand shell scopes and environment in depth. I have been reading about how if we do export VARIABLE=VALUE it will be available in subshell. So I wanted to ask a question I ...
1
vote
2answers
42 views

How do I update the dates (by 30 days) in the files going to that specific location in unix?

How do I update the dates (by 30 days) in the files going to that specific location in unix? Can awk or sed help ? File format is as below - Thomson: xyz Format: 1 Character_set: ASCII8 File_type: ...
0
votes
1answer
186 views

Linux Bash Script Ideas [closed]

I have been given the task of creating a shell script to show my proficiency in scripting. I am really struggling with ideas on what to do. I would like to create something that is relevant and could ...
0
votes
2answers
98 views

While Read loop to email

I'm having issues with a script i'm writing. I'm trying to monitor free disk space, and to have an email generated for each filesystem over a certain threshold. When using this script with 'echo' ...