A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
3
votes
1answer
19 views
Command line: crop PDF to paper size (Fedora)
Tools like pdfcrop (from texlive) are great but they seem to be too focused on removing margins/white space. I'm trying to crop a set of letter pages (8.5x11 inches) to a size of 6x9 inches. I want ...
1
vote
0answers
37 views
Command that works fine typed into terminal does not work as a bash function [duplicate]
I have a function which is meant to keep a record of every program I've installed (really, I'm interested in keeping track of dependencies). I've tested out my command in a terminal and it works just ...
0
votes
1answer
19 views
loop port variable to connect to multiple computers
I have a few raspberry pi's creating reverse ssh tunnels on an ssh server. From that server I can connect on all the raspberry pi's. I want to create a bash script that will run on this ssh server, ...
0
votes
0answers
11 views
Create a rpm package [on hold]
How can I make a rpm package to create it for my script?.
Scenario:
I have an script (many of them) and I want to be able rpm way and not using the sh such as the main application executable.
I ...
-3
votes
1answer
18 views
How do i create a sed script to prompt the user to replace a number in a file? [duplicate]
I'm new in Unix, and I'm learning about sed command. I need to write a very small script for searching a number in a file and replacing it. I tried doing grep, and than deleting the specific phone ...
1
vote
1answer
58 views
How to move a file if the folder name contains the filename
I am very new to shell scripting in linux.
I have a bunch of files in source directory. I have to move the files to the target directory where the folder should contains the file name(not exact ...
0
votes
1answer
24 views
Shell script getting 'permission denied' despite using umask 000 before command
I have a shell script (build.sh) that ends by attempting to copy some files into a new directory. However it says:
mkdir: cannot create directory
...
1
vote
1answer
38 views
How / Is it possible to install python in a portable way?
I'm working on a python script which takes care to migrate a mysql database with a certain schema / structure, into a postgresql database with a different structure.
During the development phase I ...
3
votes
2answers
74 views
Writing a script that gives how much lines have “X” and “Y” in it?
I'm doing a course in Linguistic and I would like to use shell scripts to help me doing few repetitive things such as counting who asks questions.
Here is part of the file I opened and work with the ...
1
vote
2answers
28 views
Looking for a pattern with conditions
I have a huge file in which I want to look for a word, say pattern. I'm trying to illustrate my case with an example.
Suppose I have in my file somewhere
Sample-pattern="abc"
I want to write a ...
0
votes
1answer
75 views
Creating Unix script to sleep better
I know that I try to work to late in the night and that at this time I'm absolutely unproductive, I work for 5 minutes then switch to a link seen on youtube, then come back to my work, waste some more ...
1
vote
0answers
19 views
Producing the next available filename for a pattern (02-output.log etc)
I can use mktemp(1) within a shell script to make a temporary file in a directory with a suitable suffix & prefix.
Is there a command that, given a pattern (e.g. NN-output.log) will look for ...
-1
votes
1answer
36 views
How to write a shell script (.sh file) in CentOS 6 to run commands in different tabs in the same terminal
My commads.sh file so far,
#Start the first service
cd /home/user/service1
java -jar service1.jar
sleep 5
#Start the second service
#I need this to start in another tab (if cannot another terminal)
...
0
votes
2answers
20 views
Shell script - child - background process
I have the following situation :
As root Script_A.sh is run on the server and sleeps until triggered.
When triggered, it calls Script_B.sh, which loops on the server to determine which actions it ...
4
votes
2answers
273 views
awk - combine two filters into one
I have this variable in a bash script on ubuntu 12.04 which is set to show the available MB on the root partition:
AV_MB=$(df -m |awk NR==2 |awk '{print $4}')
Is there an elegant way to combine ...
1
vote
3answers
61 views
How can convert characters into characters that'll produce beep noises?
I'm new to Linux and have recently started working on my very first (very simple) project - a morse code generator. I've been able to get the translation working, and now I want to take the next step. ...
-1
votes
2answers
20 views
collect and create tab separated matrix
I have 6 text files (each corresponds to a specific sample) and each file looks like this:
Gene_ID Gene_Name Strand Start End Length Coverage FPKM TPM
ENSMUSG00000102735 Gm7369 + ...
1
vote
1answer
29 views
bash scripting - wget or curl file with action based on the status 200 or not
I would like to write a script where I try to download a file with wget (or curl if is really not something that can be done with wget) and do 2 actions if the file exists and it's downloaded ...
1
vote
0answers
12 views
Rolling job scheduler
I have a number of servers that I want to perform the same jobs on, one server per day, once the final server has been acted upon the script should return to server1 and start over again.
The jobs ...
0
votes
1answer
25 views
How to implement config file expiration time?
I have a Debian server which runs a service using multiple config files (in a similar way to apache2) which I need to add an expiration date to. The config file that has an expiration date starts with ...
0
votes
1answer
45 views
bash script to replace server short names in a file with fqdn
I have a rather large config file that has server short names in it like this:
[host 1]
host = server1
[host 2]
host = server2
[host 3]
host = server3
I need to replace all the server short names ...
-2
votes
1answer
31 views
Replace character X with character Y in bash string
I am making bash script and I want to replace one character with another character in my string variable.
Example:
#!/bin/sh
string="a,b,c,d,e"
And I want to replace , with \n.
output:
...
1
vote
5answers
77 views
How to print nth line after match / empty lines
I'm trying to write a short script that finds empty lines and then prints the nth line after the empty lines.
For
foo1
foo2
foo3
bar1
bar2
bar3
spam1
spam2
spam3
eggs1
eggs2
eggs3
printing ...
0
votes
1answer
37 views
Bash script to read and replace string(external ip) at end of ssh config
Im in need of a script to get external ioaddress and replace at the end of an ssh config file
I have so far
#!/bin/sh
IP=$(wget http://ipecho.net/plain -qO-)
For a variable I can echo but need a ...
-2
votes
3answers
53 views
Bash script that takes a directory name as a command line argument!
Write a Bash Script that takes a directory name as a command line argument and clean the directory by removing all the files with a zero length, with a .tmp or with a .swp extension that is found in ...
0
votes
1answer
35 views
Systemd vs rc.local for a startup script post installation? (completely hands free)
I have a custom Ubuntu Server ISO that answers installation questions via preseed and kickstart files. It also installs additional .debs I've placed on the ISO during the actual installation as well. ...
-1
votes
0answers
31 views
scp erased my file, is there anyway to get it back? [duplicate]
I was trying to download a file from a remote server to my home computer using scp, but it didn't work. Afterwards, I just decided to work on the file remotely and when I opened it with vim the file ...
0
votes
0answers
20 views
How to add a new inittab entry - a script
vi /etc/inittab
startfoobar:3:respawn:/root/startfoobar.sh # added this line
telinit q
But the /root/startfoobar.sh doesn't starts. Why? SLES 11. What am I missing?
cat /root/startfoobar.sh
sleep ...
1
vote
1answer
36 views
deny use of multiple getopts arguments
I'm trying to figure out a way to deny the usage of more than one getopts args in a certain situation.
Say we have something like this:
while getopts "a:b:c:def" variable; do
case $variable in
...
-1
votes
1answer
34 views
How to check if a directory exists I don't know the exact name of it with a bash script
I need to check if a directory already exists, in this case the one with a number suffix, and I won't know the exact number. Example directories to search:
/usr/
names
names.backup
names.20160316
...
1
vote
3answers
160 views
shell scripting with large amount of files - timelapse
I have created a shell script to capture images every minutes on my raspberry pi. I think something is not quite right as it has been taking pictures but not saves them. I wonder if someone could just ...
0
votes
1answer
32 views
Bug in shell script for printing the tree-like structure of the curent diretcory
I have wrote the following script:
#!/bin/bash
if [ $# -eq 0 ]
then
read current_dir
else
current_dir=$1
fi
function print_tree_representation ()
{
for file in `ls -A $1`
do
...
1
vote
1answer
29 views
Update apt-get cache only if it's older than certain time
I'm on debian. I would like to execute an apt-get update (and maybe something else) only if the time since last update is bigger or smaller than a certain amount with a straight command, no cron ...
0
votes
2answers
77 views
What's the best way to edit a file with a bash script?
Using /bin/bash on RHEL 5.8 and I want to automate editing a file. I need the script to search the file and replace a line in the file. Line example:
Other line
Current date 01121990
Other line
...
0
votes
0answers
12 views
Linking and combining text from different documents into dynamic document
I am taking notes on many, related topics from multiple sources. For instance, one of the sources is a textbook on machine learning. I type the notes in an .odt document (but whatever, it could be ...
0
votes
1answer
35 views
My if bash script always execute the break
I`m making a script to rename files in a folder. The new name for the files is in a config file. I have to be sure that the file I want to rename corresponds to the current one in the config file. My ...
1
vote
2answers
39 views
Change Directory and execute command automatically then change directory back out
I'm attempting to write a script that will be run in a given directory with many single level sub directories. The script will cd into each of the sub directories, execute a command on the files in ...
0
votes
2answers
60 views
If filename has more than n characters, delete the last ones
I'm kinda new with the unix shell, and I don't seem to find the answer of my problem :
I have a folder containing multiple files : a correct filename contains exactly 13 characters (numbers + letters ...
0
votes
0answers
13 views
How to move a postgresql backup dump to an other server with a script?
I have on a ubuntu 14.04 Server some Backup Files from a PostgreSQL Database. How Can I move this with a daily backup script to an other server?
I need a script that moves my files in path ...
-4
votes
2answers
45 views
get the input from a script and echo it to another file
I have a python script that create some files and it ask me to enter a password this script is called from bash script
is their any way to get the entered password and echo it to text file
-1
votes
2answers
38 views
Why would a user not be able to delete a file they created
Reposting the question about deleting a file. We have a script that is used to transfer files between two SCO Unix systems. The script has been rock solid for years. Recently the firewall unit at ...
0
votes
2answers
38 views
How to output some data to different cells of an Excel File?
Example:
I have a file that has following data:
cvrta2100 Error 404 Fixed
cvrta2111 Licensed Needs Fixing
cvrta2123 Error 404 Fixed
cvrta2333 Licensed Needs Fixing
I am using awk to print ...
0
votes
0answers
11 views
Simple xdotool UI automation login script in Debian 8 VM on Windows 10 host doesn't work when VM starts for first time after Windows BSOD
I do time-lapses with computer scanners using VueScan in Debian 8 VMs using VMware on a Windows 10 host workstation. I made a script that runs when the VMs start up that mounts a Windows network ...
3
votes
2answers
27 views
Searching /usr/dict/words to find words with certain properties
I would like to write a script to search through /usr/dict/words to find all words that meet some criteria I specify. For example, finding all palindromic words (like "racecar", "madam", etc.) or ...
1
vote
1answer
50 views
Execute an online script gracefully
Context
I've set up a site to post scripts to which I can then execute later using the following command:
curl -so /tmp/script http://scripts.programster.org/scripts/1?output=raw && . ...
0
votes
0answers
18 views
Boot portable linux image and auto run script from bootable usb
So I was wondering of the if there was anyway for be to boot up a portable linux OS and have it autorun a script after it loads up. I was hoping to use something simple such as TinyCoreLinux or ...
1
vote
2answers
24 views
Wait until gnome-terminal ends
I'm trying to implement a script who runs four terminal window in parallel using this function gnome-terminal -e sh -c "python scraper.py".
I would like to know if there's a way to wait until each ...
0
votes
0answers
12 views
journald 'forgets' correct unit name for shell-based units?
With a unit file like this one here, and an (exectuable, with shebang) shell script as named:
[Service]
Type=oneshot
ExecStart=/some/shell/script.sh
I get journal output like this:
Mar 10 17:11:27 ...
0
votes
0answers
15 views
How to check the status of the latest aide run after login, and test if it's done less then 24h(green) or more then 48h(red)?
-Green: No changes detected and last AIDE run was less then 24 hours ago
-Red: Changes detected or last run was 2 days ago
I tried to grep the timestamp from the log file /var/log/aide/aide.log which ...
0
votes
1answer
33 views
Editing the variable PATH
I want to start script just by typing script not the full path of the script for example ~/Desktop/name/script so i tried to edit variable PATH
PATH="$PATH:~/Desktop/name"
in the name folder i have ...