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)

-3
votes
1answer
67 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 > ...
3
votes
1answer
76 views

Full screen terminal with script as screen saver under archLinux

Bonjour, Is it possible to run a terminal at full screen running a script instead of the screen saver ? That means that after 10 minutes of inactivity the screen should go black and show the STDOUT of ...
8
votes
4answers
17k views

How to send multiple commands to sftp using one line

The following command sends one command to sftp using one line: sftp -o PasswordAuthentication=no user@host" <<<"lcd /home" How to send multiple lines to sftp using one line. Is there a ...
5
votes
1answer
3k views

Differences between %pre and %post in Kickstart on CentOS?

I have been setting up machines with Kickstart on CentOS and I am unsure about the differences between the %pre and %post sections of the kickstart .cfg file. The CentOS Documentation for the ...
1
vote
2answers
264 views

delete redis keys that have been inactive for 30 days

I've installed a web app called scrumblr which uses redis as a database. What I am attempting to do is delete all keys that have been inactive for 30 days, or have not been accessed in 30 days. I ...
0
votes
2answers
34 views

Copying script files using wildcards

We have an SFTP location which is shared by two processes. Now we have a situation when we need to filter based on the filenames before copying. ClientA12345.out ClientA44378.out ClientB23478.out ...
0
votes
0answers
20 views

Automated port change

I want to Create a Bash file that a user can execute to change the port a service runs on. Essentially all I have to do is replace a number in a line of text with another number generated by a list. ...
0
votes
1answer
16 views

The unalias in the Mysql Backup script

Here's the script to back up Mysql database. #!/bin/bash FILE=minime.sql.`date +%F` DBSERVER=127.0.0.1 DATABASE=wordpress USER=root PASS=789789 unalias rm 2> /dev/null rm $FILE 2> /dev/null ...
1
vote
1answer
20 views

Mean and variance of words pronounced

I'm working on linguistics and am trying to calculate the average sentence length and how much this average varies. I worked to leave always one sentence per line For instance: La dernière fois ...
3
votes
2answers
104 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 ...
9
votes
6answers
1k views

Modify a file without creating another file

Is there a way to modify a file without writing the contents to another file, without sed and awk? For example: $ cat test.txt aaa aaa bbb ccc ddd Replacing using sed with -i option, sed -i ...
-1
votes
0answers
34 views

Bash script not quite working

First of all I am new to scripting / programming of any kind so have very basic understanding. I found this script and it does what I want it to do, except at the end I can't send the variable $msg to ...
0
votes
0answers
12 views

Bash script not passing variable through ssh [duplicate]

I'm trying to write a script that will ssh into multiple servers and echo the line user_pref("plugin.state.java",2) into every user's firefox pref.js file. I keep getting the error bash: ...
0
votes
1answer
43 views

Copy last n-lines from one file to another

In the context of adding the same lines at end of the .bashrc or .vimrc files of several user accounts on the same machine, what would be an easy way to copy the last n-lines from one shell script to ...
3
votes
2answers
129 views

How to extract strings from one file into multiple files

I have a file, xxx.lst with the following data: aaa 111 bbb 222 ccc 333 I need to make 3 files called 111.lst, 222.lst and 333.lst respectively with aaa in 111.lst bbb in 222.lst and ccc in ...
1
vote
1answer
146 views

script can't write to systemd journal

to make it short: I want to write to the systemd journal from a script. printf "%s\n%s\n%s\n" CODE_FILE=/etc/zsh/zprofile CODE_LINE=31 MESSAGE="could not read /etc/dircolors" | logger --journald ...
-1
votes
1answer
31 views

negation equivalence

I have this exercise: Write a script, which uses if-then-else-fi and accept sequence of parameters -a and -b with values "true" and "false", while for every pair writes negation of expression -a ...
0
votes
2answers
37 views

Command to merge all terminal windows?

Is there a terminal command that merges all open terminal windows into one window with tabs? Been searching all over the place, but have yet to find any solutions.
0
votes
1answer
19 views

Count ONLY alphanumeric words in a specific column of a file

It's essentially what the title says - I'm given a test file and am supposed to be able to count the words in a specific column of a file. The catch is that there are some lines that contain only ...
0
votes
1answer
38 views

How to execute a script on SSH Login or device bootup/shutdown? [duplicate]

I have a raspberry pi, which is online and connectable by SSH. What I want to do is create hooks for the following states: When the device starts Before the device shuts down When an SSH login ...
3
votes
1answer
32 views

Why does this fish script does not run from a launcher?

I've written the following script, intended to start a daemon and display a Zenity window, then stop the daemon when the window is closed: #!/usr/bin/fish if not ps aux | grep [s]erviio > ...
0
votes
1answer
32 views

How can I get my bash script to remove the first n and last n lines from a variable?

I'm making a script to preform "dig ns google.com" and cut off the all of the result except for the answers section. So far I have: #!/bin/bash echo -n "Please enter the domain: " read d echo "You ...
1
vote
1answer
932 views

How do you make case statements with ranges

I'm supposed to: Make a case statement that will display the a grade after input. With no loop or conditional. A=90-100, B=80-89, C=70-79, D=60-69, F=0-59 This is what I have so far: ...
0
votes
1answer
3k views

How to execute grep in tcl for getting XYZ-123 type pattern

How can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
0
votes
2answers
70 views

Unable to execute bash script inside expect script

i have a expect script like #!/usr/bin/expect ..... spawn passwd expect "password:" send "password" .... .... .... ~/test.sh Wile executing this, I'm unable to run bash script test.sh. How to ...
0
votes
2answers
916 views

Permission denied when run script via ssh

I wrote script which download via scp and install some packages. SSH keys are added to host and when I run [root@HostB ~]# ./myscript everything is ok and packages are downloaded via scp without ...
0
votes
1answer
40 views

practice linux for practical use [closed]

I have learned and studied linux for 6 months with books like 'The linux commandline'. But, I'm just student, not a business man. When I study linux and do not use it for long time, I always forget ...
0
votes
0answers
21 views

How to generate following output file by using PBS script language?

I need to run interacting job with such specifications by using PBS on the cluster. This job must write the output file, in which there is following information (I have not specify this in the .pbs ...
-1
votes
3answers
42 views

In a bash shell script , how to write a loop that goes trough three values [duplicate]

I'm trying to write a shell script using bash for the following problem: Write a loop to go through three values (A B C) and displays each of these values to the screen (hint use a ‘for’ loop). ...
1
vote
1answer
35 views

code to display the text TRUE

I'm a complete newbie and I'm starting to learn the basic for shell scripts. So I apologize if this question is very simple for most users. I'm trying to display the text TRUE to the screen if a file ...
3
votes
1answer
34 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 ...
0
votes
1answer
39 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, ...
1
vote
0answers
38 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 ...
1
vote
1answer
67 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 ...
-3
votes
1answer
25 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 ...
0
votes
1answer
30 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 ...
0
votes
1answer
79 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
1answer
53 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 ...
1
vote
2answers
29 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 ...
1
vote
5answers
131 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 ...
2
votes
0answers
22 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 ...
8
votes
1answer
972 views

Can capabilities be used in scripts without setcap'ing the interpreter binary?

Right now I'm using cap_net_bind_service MY_USERNAME in /etc/security/capability.conf. Now I just need to set cap_net_bind_service+i on the interpreter of my favouite scripting language to be able to ...
5
votes
5answers
5k views

How do you colorize only some keywords for a bash script?

I am running some unit test code. The unit test code outputs regular text. There is a lot of the text so I want to highlight for the user important keywords. In this case the keywords are "PASS" and ...
-1
votes
0answers
71 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) ...
1
vote
3answers
69 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. ...
0
votes
2answers
23 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
283 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
votes
2answers
25 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
45 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
15 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 ...