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 (1)

5
votes
3answers
127 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
23 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
7 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
15 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
45 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
68 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
48 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
14 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 ...
-1
votes
0answers
19 views

How to query an Oracle database and e-mail the results [closed]

I have an Oracle database. How do I go about running an SQL query on it, capturing the results in a text file, and e-mailing that file? If there are no results, the e-mail should just say that there ...
0
votes
1answer
38 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
45 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
28 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
0answers
17 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
160 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
19 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
96 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
16 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
11 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
39 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
0answers
16 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
31 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
35 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
39 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 | ...
13
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
29 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
122 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
21 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
93 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
34 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
247 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
109 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
33 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
1answer
24 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
63 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
70 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
62 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
29 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
30 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
31 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
40 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
38 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
92 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
38 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' ...
0
votes
0answers
15 views

Perform task on waking up from suspend

I have program that misbehaves when my pc wakes up from suspend to ram, it starts using up to 40% of processor time so i usually have to kill it manually. How can i set specific command (pkill in ...
6
votes
2answers
939 views

How to make a temporary file in RAM?

I have a script that will pipe its output to |tee scriptnameYYMMDD.txt. After each cycle of the for loop in which the output is generated, I'll be reversing the file contents with tac ...
0
votes
1answer
17 views

I'm trying to deploy with git to a semi-managed vps, need to write a script to change owners

I'm trying to deploy my sites on my company's semi-managed vps server using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps It ...
0
votes
1answer
13 views

How to force decimal addition (#10) when adding numbers with a carry (octal issue)

How can I get 10#1$result to work correctly? When creating a calculator for adding two numbers I am adding together by transversing the digits from small to large. e.g. for adding 51 plus 51 I am ...
-1
votes
1answer
31 views

Command output to file, new lines at beginning

I'm rewriting some 20+ year old Unix scripts and I want the output to go to the screen and a file. I know this is possible with tee. Is there a similar command that stacks new lines on top, at the ...
2
votes
1answer
42 views

use mutt to send email through specific port on CentOS 7

What specific syntax do I use to get mutt to send an email through port 587 on a CentOS 7 server? For example, the sender is me@mydomain.com, the recipient is someone.else@someotherdomain.com, the ...
0
votes
1answer
36 views

Avoid conversion to scientific notation in awk

I have a csv file that contains hundreds of columns. I would like to subtract the value of a specific column from a static number and then print the entire line. The values of that column are long ...