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)

0
votes
0answers
63 views

Bash, find and delete old files

Write script for backup files and delete old: #!/bin/sh BACKUPDIR=/var/backups/files ROTATE=1 mkdir -p $BACKUPDIR CURRENT="$BACKUPDIR/`date +%Y-%m-%d`-files.tar.gz" cd /var/ && tar czf ...
1
vote
1answer
55 views

Can I execute a script before every login

I am planning to have a program that will need to connect to a server. I'd like to be able to send a encrypted password to my server. The thing is, I need my decrypting script to be executed ...
2
votes
1answer
26 views

How to create gcov files for a project in a different dir?

I want to analyze code coverage datas. I want to create gcov files from OpenSSL (and from other projects), but I can only create them in the same directory of the project, and only for the files in ...
2
votes
2answers
42 views

Delete Entries in File if the Same Entry Exists in a Master File

I have a JSON master config file whose value may be overwritten by a specific account's config file (also in JSON). The Master file has this structure: { "section1Configs": { "setting01": ...
-1
votes
2answers
43 views

Find file, Edit text within files

Im trying to find a file then edit the text within these files. This is what I have so far, but sadly Im not that well versed... Help Please? grep -rl "wrongtext" ~/Library/Calendars ...
8
votes
7answers
2k views

How can I make a script to count up by fives?

I was trying to make a very simple bash script to list all of the multiples of five between 375 and 3500 (375, 380, 385...). One thing that I tried and didn't work is: for i in {375..3500} do ...
2
votes
2answers
86 views

Merge two-columns files into one file

I have a bunch of files (file1, file2,file3, ...) with two columns. For example, file1 looks like: 0.12 0 0.32 0 0.42 1 0.23 0 and file2 looks like: 0.34 1 0.55 1 0.31 1 0.99 0 I wonder how to ...
3
votes
4answers
377 views

Add path to $PATH if not already in $PATH [duplicate]

I need to add a path in a bash script, but it may be executed several times: export PATH=${OPENSHIFT_HOMEDIR}/app-root/runtime/bin/:${PATH} I don't want that path to be added over and over. How can ...
0
votes
1answer
16 views

Problem with inotify-wait as daemon

I have been running inotify-wait on my ftp server in byobu to monitor a folder, move data, and send email notifications for a few months without problems. Since I started this I have added 3 more ...
0
votes
1answer
55 views

How to execute shell commands in a loop from within a bash script?

I am new to bash and need help badly. I want to write a script which will run on my android phone & perform the following things: echo "1" > /sys/kernel/mm/ksm/run wait for 2 minutes: then ...
-3
votes
0answers
19 views

How to switch 2 scripts based on browser size? [migrated]

I'm new here. I'd like to ask if you can switch 2 scripts using a script? Currently, I have 2 different sizes of banners which are being called using invocation codes. Invocation code for 728x90 ...
1
vote
2answers
37 views

Else not Executing

In my script, I transform data to a more readable format. But I am having an issue. If no arguments are typed, just the script, I want it to come back "Please enter a filename" which I have done. But ...
0
votes
0answers
16 views

Formating VGA info to conky

I'm trying get conky working on my system, and I'm stuck on how to format an specific shell variable to display my VGA. From shell I get my VGA using: lspci | grep VGA The output: 01:00.0 VGA ...
2
votes
1answer
29 views

How to create a zip of directories -mtime -150

I want to zip the directories, sub directories, files in main and sub directories from today till 150 days ago. I only consider the date of the directories where I am running the command, no matter ...
1
vote
0answers
26 views

Can't get bare-bone simple bash function to work [closed]

I have some tmux scripts in a directory, and I'm trying to make a script to make it easier to call them. Function is below tms() { ~/linux/scripts/tmux-scripts/$1 } This is in my bashrc, I then ...
-1
votes
1answer
37 views

How to edit a file from a script using find and replace? [duplicate]

Here is the sample of the code of what my intent is for such a script: #!/bin/bash Update=$1 if [$Update == Value] then NewValue= $Update vi %s/Value/$NewValue/g > Updatedfile fi ...
0
votes
2answers
33 views

Cannot login after making a service autorun at startup [Debian]

On a normal startup after booting the login prompt appears from where I would login. But after making motion autostart I am unable to login or open GUI because motion is using the command line to ...
0
votes
3answers
41 views

Shell append string after last match

I would like to insert a string after the last match, example: String to insert after last instance of banana: Orange Input Apple Banana Apple Banana Output Apple Banana Apple Banana Orange I ...
0
votes
1answer
28 views

Auto Download & Untar Script

Looking to write a script for my Linux Server so look for a specific folder name, then wget a file, and untar. Where would I start with this? I know that it has to be written in bash, but I'm very ...
4
votes
3answers
144 views

Bash script: do something one time inside a loop then stop, but continue looping

I have a Bash script that checks my laptop battery and sends me an Android notification (via shuttle, a Bash script I wrote that serves as a cli interface for the Pushbullet API). It works nicely, but ...
-1
votes
1answer
43 views

Whats wrong with the 2nd script?

I am new to linux and scripting. I have some concerns regarding the script below which creates folder per line from file. Folder.list is located in /scripts/ . 1st script works smoothly but the 2nd ...
2
votes
0answers
21 views

How can I tell whether or not I am in a text area?

I am running a Window Manager and am soon getting a Thinkpad x220 tablet. I was hoping to make the tablet a little more functional by having an on-screen keyboard, and I have set it up so I can ...
0
votes
1answer
47 views

How to find out last run time of shell script?

I am trying to find out at what time the shell script ran last time within the shell script. I tried: ls -laru ls -lart but all these commands give me the last modified time and last accessed ...
0
votes
4answers
59 views

Copying Only Directories With Files

I am trying to copy files and the directory it is in to another location. I can find the path like this: find ~/dim_import/* -type f ! -name xdir | cut -d '/' -f 5-10 which outputs ...
1
vote
1answer
56 views

sh - Using Arguments in .profile functions

I want to use an argument in the function I created in my .profile file. I want to ask for input if no argument is given, otherwise set a variable to $1. When I check $1 to see if it is empty, I ...
0
votes
1answer
40 views

How to calculate Swap warning/critical dynamically through script?

I have used SAR in my below script and is trying to run on individual servers for my nagios monitoring. Can someone please suggest how i can get the swap warning and swap critical values in my check ...
1
vote
2answers
74 views

How do I scp a file from server A to server B from cron?

I have a file in server A which I am able to do transfer to server B using scp. I need to do this through a cron entry. server B has a password. How do I perform this?
0
votes
1answer
49 views

Select latest updated file from directory and send it via email

I want to select latest error(timestamp).log file from some directory and send it via email as attachment. What I am trying is: Filename: abc.sh echo 'An error occured' | mutt -s "Logs" -a ...
1
vote
2answers
193 views

Bash script to read file and echo different lines to output files [duplicate]

I have a log.txt file with various lines of strings and information. I want to write a script to read the log.txt file line by line and any line that contains the word debug I want to put that line ...
0
votes
1answer
47 views

/bin/sh script error “arithmetic expression: expecting primary: ” + “ ”

ERROR: ./client-disconnect.sh: 22: ./client-disconnect.sh: arithmetic expression: expecting primary: " + " I just need to know how to fix it. It's for user accounting with OpenVPN. Script ...
1
vote
1answer
23 views

What's the Fedora equivalent of /var/lib/dpkg/info/[…].prerm?

Example file: /var/lib/dpkg/info/util-linux.prerm What's the Fedora equivalent of this file? (Not limited to util-linux - generic question for any package.) Use case: A prerm script is failing. ...
-3
votes
1answer
26 views

Need help running a command based on a file in the directory

I have some scripts setup that I would like a master script to call based on a files appearance in a directory. Basically I have what's show below. Script A uses file a Script B uses file b ...
1
vote
0answers
28 views

Script for changing monitor refresh rate when fullscreen on a specific website.

Premise I recently discovered this website where I can watch legal streaming of plenty of animes. They use a flash player and the CEO said that, for legal reasons, they can't use a HTML5 player. The ...
1
vote
0answers
23 views

-devilspie doesn't play nice with spawning new terminals

I'm trying to configure devilspie so that on detection of opening a certain directory it runs a script to mount that directory over a network. I don't think the script itself is too important but ...
2
votes
3answers
53 views

Split command and arguments, and put into variable in a bash script

I have a script that repeats the same (very long) grep command many times. I want to make the script more readable by cutting the line length, so I tried to put parts of the command into variables. ...
1
vote
0answers
18 views

Creating and mounting partition automtically

I am running raspberry pi on raspbian wheezy, and I'd like to create script that automatically creates new partition on unused area of disk and mountpoints on it so it'll always mount on same ...
0
votes
2answers
53 views

viewing printf after pipe (or subshell?)

Ok, this is hard to distill to a single question because it really depends on how I'm going to troubleshoot it. The following script is meant to pipe mount.cifs commands to a while loop that enters ...
4
votes
3answers
341 views

Exiting a shell script with nested loops

I have a shell script with nested loops and just found out that "exit" doesn't really exit the script, but only the current loop. Is there another way to completely exit the script on a certain error ...
1
vote
0answers
10 views

Application started in /etc/X11/xdm/Xsetup can't receive key presses

I'm using xdm (and I'd like to keep it that way) for a project and I need a terminal to run a script before the login prompt. The script requires some user input, however, it doesn't seem to work. ...
0
votes
2answers
44 views

Why Are There Three Processing Running For One Script?

I have the following line in crontab. @reboot /usr/bin/teamspeak3-server_linux-amd64/ts3server_minimal_runscript.sh When I reboot, the script runs (i.e. my Teamspeak 3 server starts) in the ...
0
votes
1answer
52 views

A bash script that can automate git commit message contents

Normally when I commit a change to a submodule in Git (and if that's the only change), I will provide the result of git diff <submodule-name> to the body of the commit message (with ...
0
votes
1answer
19 views

Old file deletion script

I used this script: #!/bin/sh for file in "$( find /var/backup/web2 -type f -mtime +1 -maxdepth 1 -exec rm -f {} \; )" do rm -f $file done exit 0 to delete files older than 24h from fixed ...
0
votes
1answer
18 views

Substituting the value with spaces for a variable in bash script - the correct way

I have a compilation script that can compile the program with and without the debug symbols. I want to ask via bash prompt ( read ) the user to choose whether he wants a debug version or not with ...
1
vote
2answers
59 views

How do i search for certain sections of a file and then extract only relevant information within that section?

So I have a text file that is a server report and has about 1000 lines of information in it. I'm trying to write a script that can search the report for only certain pieces of information I'm looking ...
1
vote
2answers
36 views

Why does trying to run a python executable return ': No such file or directory' after transferring it to server via FTP? [duplicate]

I'm having an issue where when I transfer a Python file to my VPS via FTP and try to run it using ./foo.py I am returned with the error: : No such file or directory. The error seams to indicate that ...
3
votes
3answers
68 views

Converting rows to row groups

Can somebody please help me with the below conversion shell script ? Source File File 1 : for example EXCHANGE_ID : 192, 410, EXCHANGE_DTTM : ...
0
votes
2answers
70 views

Bash script that detects if a file is the correct size

I'm trying to make this bash script dispatch and email when it detects that a certain type of file (files ending in ".gz"), which was last modified 24 hours ago, is below a certain size in a ...
1
vote
1answer
28 views

Application Shortcut To Launch On System Boot

I have a ts3.desktop file in my /usr/share/applications folder that I want to run on system boot. Can you please advise me on how this can be done?
0
votes
0answers
21 views

Can rpm call an external script stored somewhere in the package during installation?

I have a package which is being retooled for in house purposes. Mostly making changes to the configuration files. The files need to be somewhat dynamic so changing the config files at source isn't ...
1
vote
1answer
62 views

Bash script to edit text in csv-format

As part of an inventory bash script I am checking SFP modules and adding them to a .csv-file. The format currently looks like this, with varying lengths: RO01;1000BaseSX SFP;1000BaseSX SFP ...