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)

9
votes
5answers
8k views

How can I print only certain commands from a bash script as they are run?

I have a bash script with various if statements based on command line arguments I pass in when calling it. Having some kind of output as to what commands are being run is helpful to confirm the flow ...
0
votes
2answers
28 views

Script input filename or standard input

#!/bin/sh read vstup if [ -f "$vstup" ] then cat $vstup else if [ $vstup = "-"] then while [ $stadvstup != "q"] do read $stadvstup >> temp.txt ...
3
votes
2answers
29 views

Best way to delete select email messages from mbox file using script

I have an arbitrary email messages file in mbox format. I would like to periodically (end of the week), and automatically (via cron) purge messages from my "alerts" mbox file (new folder) just from ...
0
votes
1answer
41 views

Bash script fail to detect disk

I got a script that is supposed to reformat and mount /dev/disk/by-label/backup_disk into /mnt/backup_disk. Like this: /sbin/mkfs.ext4 -q -L backup_disk /dev/disk/by-label/backup_disk mount -t ext4 ...
1
vote
2answers
24 views

Script - numberlines

I would like to make a script, which allows user to input some text and it will output the same text with number of lines. Example: Input: Hi Jack, how are you? Output: 0001: Hi Jack, 0002: how ...
1
vote
1answer
55 views

Safe way to install .sh script in /usr/local/bin?

I want to include correctly the following script in Ubuntu 16.04. Code #!/bin/sh # http://tex.stackexchange.com/a/20886/13173 # $Id: pdf2eps,v 0.01 2005/10/28 00:55:46 Herbert Voss Exp $ # Convert ...
0
votes
1answer
36 views

Script too slow ? Any particular reason?

I have a script which does hexdump along with pipeline commands and finally I am redirecting it to a file. Now I am logging data from the serial port of my Raspberry Pi. I also call a python ...
0
votes
0answers
38 views

Matching number using grep [on hold]

I have this text: yuiopao:##yuiopao:14975:Alex Vart student:/home/stud/yuiopao:/bin/bash polkovar:##polkovar:5004:John Adi student:/home/stud/polkovar:/bin/bash gfgfdgd:##gfgfdgd:11000:Alan ...
0
votes
2answers
508 views

Unix Shell script to delete all traces of itself after execution through crontab

My Question has 2 parts. Help with both parts is greatly appreciated. GIVEN INFO: - Lets assume there are 2 Folders, Folder A and Folder B. - Folder A contains many files. - Folder B contains the ...
1
vote
0answers
24 views

Access to bash arrays in gnuplot [duplicate]

In a bash script I have several arrays which I need to access in a gnuplot code: #!/bin/bash ... # fill array a[*] and b[*] ... gnuplot <<EOF do for [j=0:10] { # access ${a[j]} and ${b[j]} } ...
-3
votes
1answer
59 views

Need help in a shell script

I need help with the below shell script. I have three environments: test, dev and prod. When the user enters test it should ftp to test host and ftp the file. Same in case of dev and prod. I have just ...
1
vote
0answers
12 views

Linux Mint Corners Musical Sequence Associative Array

I am writing a script which uses hot corners to play specific musical notes when hovering in corners, and depending on the musical sequence to execute a specific command. The script is called with ...
0
votes
2answers
57 views

Using regular expression to extract content of file [on hold]

I have a link and I would like to return only content between www. and .com e.g www.blablabla.com would return only blablabla How could I do that? When I use grep '\.[a-zA-Z0-9\.-]*\.' it gives me ...
0
votes
0answers
25 views

Alternative for 'select choice in' in ZSH script? [closed]

I need to use a shell script in my ZSH terminal. The script was written for bash, and uses select choice in/do. This script sets environment variables, so it needs to be run by calling source ...
1
vote
1answer
107 views

Evaluation of find ( -exec )

I'm searching for all files that contain one of a set of strings. If they do, I change their access rights. find . -type f -exec grep -q '#!/bin/bash\|#!/usr/bin/grep\|#!/usr/bin/awk' {} \; -exec ...
6
votes
1answer
228 views

How to use less in a script without getting ESC escape characters?

When I use less at the command line the output is like but when I use less from within a bash script I get: How can I use less in a bash script and not get all the escape characters and have it ...
0
votes
1answer
19 views

Filtering time using last command on Solaris

I'm connected on server using Solaris and need to filter only people who were connected there until 28.4 00:00. How do I do that on Solaris? In bash I have -t option which does what I want.
1
vote
2answers
954 views

script to add users to otrs

Im looking for a fast way to import customer users into otrs (ticket system) I have an export from Active Directory with: firstname lastname password email username There is a script in the otrs/bin ...
5
votes
7answers
9k views

Sort the files in the directory recursively based on last modified date

Sort the files in the directory recursively based on last modified date I have modified a lot of files in my directory want to know what are those files by sorting them by the last modified date ...
0
votes
1answer
29 views

In UNIX, how do I send a file back to it's original location after outputting it somewhere else? [closed]

If I send a file into a directory using an output, is there a way to bring that file back to it's original location using a shell script?
1
vote
1answer
18 views

Trying to copy/paste long script with multiple EOFs, Terminal starts running half-way through

Was trying to create a text block that I could just copy and paste into a Terminal window to accomplish something (in this case, create a systemd script to do maintenance on MySQL dbs, create a timer ...
1
vote
4answers
31 views

Compare characters

I have two lines, which are saved in two variables. But it doesn't really matter, where they are saved. My question is, how do I compare each character from both lines? For examples Hello Hlleo ...
-1
votes
2answers
45 views

Where can I practice my Python and Bash scripting? [closed]

I wanted to practice my bash scripting skills and python skills and wanted a good book or a site where I can practice and get excellent skills please. Any recommendations please.
1
vote
1answer
39 views

Bash print current line, line's output, and linebreak to file

I've got a txt of a bunch of domains I need to run dig +short mx on. I've got a script set to run the command, print it to a results.txt with: ./dig_domain_mx.sh > results.txt Downside is, I ...
1
vote
0answers
21 views

Script - printing specific lines [closed]

I would like to print every line from text file with for loop, but somehow it doesn't work. It writes error: head: invalid option -- 's' I haven't used 's', so why it output with this error? ...
2
votes
1answer
715 views

Error passing variable from bash to php

I have the following files: vars.txt C=1234567890 Ascript.php #!/usr/bin/php <?php var $C="$argv[1]"; echo "\n $C \n"; $con = mysql_connect('localhost','root','123') or die ("No connected"); ...
1
vote
1answer
859 views

Error QProcess: Destroyed while process is still running

Edit: I discovered that the problem is not related with the script cited below, but I'll leave it there just for history. Well, this error appears when I close texstudio with the viewer open (xdvi or ...
-3
votes
0answers
22 views

script - typing with all ten [closed]

I would like to make a script, which works as usual typing with all ten fingers program. I imagine that script will accept the parameter: which textfile to show. And then it will read user input and ...
4
votes
4answers
4k views

How can I extract/parse a complete URL from a semi random string?

I'd like to have bash parse/extract a full URL (and only the url) from a random short string. Examples: bob, the address is http://www.google.com or https://foo.com/category/example.html is up ...
0
votes
3answers
23 views

Getting the first 5 characters of unix filenames

I have Unix filenames like the following and I need to extract the first 5 characters of the filenames. I know you can use cut to extract the field content but I’m looking for getting the first 5 ...
-1
votes
1answer
20 views

adding date to beginning of file name using script

I have multiple files that need to be renamed with a date added to the beginning of the file name that I am trying to script. I'm using the cp command because I need to keep the original file I need ...
0
votes
2answers
42 views

List Most Recent File per Sub-Folder

I have a File structure of : FOLDER/SUB_FOLDER/Text_File I have over 1k+ FOLDER and each FOLDER has at least 2 different SUB_FOLDER with each SUB_FOLDER their own Text_File. I'm trying to ...
-2
votes
2answers
57 views

Keep CPU busy at certain percent (to prevent CPU buzzing frequency noises) [closed]

On Dell Inspiron 7559 there is electric buzzing from beneath the keyboard that changes frequency when I touch the touchpad. However, if the CPU is busy I hear no buzzing as the frequency gets out of ...
0
votes
0answers
53 views

Executing remote code with arguments

Why this: ssh -i ~/.ssh/master.pem ec2-user@xx.xx.xx.xx 'bash -s' < `dirname $0`/elements/"$element" returns hostname.sh test-5000: No such file or directory when $element is not a just a single ...
6
votes
3answers
77 views

sed/awk subscript numbers in chemical formulas using markup tags

I have hundreds of text files that include chemical formulas together with narrative including numerical values. The formulas are always preceded by white spaces but can be followed by white spaces, ...
14
votes
5answers
26k views

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
0
votes
2answers
2k views

VLC script on ubuntu server

I need a small script which run three vlc command on the same time (on Ubuntu server 14.04) as stated below: #!/bin/sh cvlc -vvv v1 --sout ...
-2
votes
1answer
64 views

quick and easy way to comment out multi lined print statements

Is there a quick and easy way to comment out multi lined print statements? something like this? printf("3387 strings_line_tokens[lower_bound_of_big_boy_counter] %s \n", ...
15
votes
7answers
7k views

Using notify-send with cron

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron. I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without ...
0
votes
1answer
34 views

How can I avoid being prompted for a password in this script? [duplicate]

I’m using Amazon Linux. If I login as my “otheruser” user, and create a script, test.sh, with this text sleep 5 ; sudo reboot now I can login and run the script like so … [davea@mydevbox ~]$ sudo ...
0
votes
1answer
52 views

Parse xml returned from curl within a bash script

I've been digging through stackexchange for the past few days and I've found bits and pieces of what I'm trying to accomplish, but I'm unsure how to put it all together... I'm trying to create a ...
4
votes
5answers
201 views

How shrink test -eq expression with more than one var value in /bin/sh

#!/bin/sh if [ $num -eq 9 -o $num -eq 75 -o $num -eq 200 ]; then echo "do this" elif [ $num -eq 40 -o $num -eq 53 -o $num -eq 63]; then echo "do something for this" else echo "for other do ...
0
votes
1answer
2k views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
0
votes
1answer
25 views

Source ~/.bashrc when using the shell recorder `script`

I am using the first answer from How to automatically record all your terminal sessions with script utility to record my terminal sessions, however, I can not figure out how to get my bashrc to be ...
1
vote
3answers
2k views

Split XML file into multiple files

I have an xml file that have different nodes, I want to split files like this: <unix> <mm> </unix> <osx> <nn> </osx> When I run the script I want it to make ...
0
votes
1answer
27 views

How to Wget with Subset Condition?

I want to download a subset of data recursively in the website that is within HTML class .container current main page in .container daughter pages of links also in .containers in daughter pages ...
3
votes
1answer
38 views

How to revoke access for a particular user?

How can I revoke all access (r,w,x) for a particular user to a file or directory tree (while still giving read permission to others)? Does setfacl with mask allow this ?
1
vote
1answer
164 views

How to kill inactive user logins on Solaris?

On a Solaris 10 server if i do a w, I get this: 12:26pm up 85 day(s), 1:13, 6 users, load average: 0.38, 0.36, 0.38 User tty login@ idle JCPU PCPU what blah pts/1 ...
0
votes
1answer
23 views

Script which reacts to interrupt signal [duplicate]

How to make a script, which will write a string "signal caught" after sending 'interrupt signal' (after pressing ^C on the console, where the script was executed). On top of that after pressing third ...
-3
votes
1answer
66 views

Script to clean log files does not delete them

Could someone explain to me why this script does not delete /var/logmessages and /var/log/wtmp files? I found it on tldp.org tutorial #!/bin/bash LOG_DIR=/var/log cd $LOG_DIR cat /dev/null > ...