Questions tagged [scripting]

A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

Filter by
Sorted by
Tagged with
1
vote
1answer
13 views

How to search and replace for multiple words in one shot

I need to search and replace multiple words. For example, in my file, I want to search fro any name of week days that appears with a comma after it: Sat, or Sun, or Mon, or Tue, or Wed, or Thur, or ...
1
vote
0answers
15 views

Using a file list to apply a script over a set of similarly named files (unix)

I have a set of files that are named like this: NAM11_BW415_R1.fastq.gz NAM13_BW968_R2.fastq.gz NAM17_AC_Barrie_R1.fastq.gz NAM3_PI648600_R2.fastq.gz NAM7_Glenlea_R1.fastq.gz ...
0
votes
1answer
17 views

Run scripts at logout

Sometimes I ssh into a box, and run some script that makes a change to the system. I want to undo this change when my session ends, either explicitly (e.g., via exit from the logout shell) or ...
-2
votes
0answers
38 views

How can I detect and remove tab and newline character, from within a column in a file in Unix [on hold]

Input: A B C D E F 1 11 {1} 22 3 4 5 55 99 7 8 9 10 {9} 44 33 42 55 22 66 I use {} to highlight the tab and new line character. Expected output A B C D E F 1 ...
1
vote
1answer
33 views

How to write an “expect” script that checks if the supplied password matches one of multiple possible passwords?

I want to change the password on my server. There are four possible passwords that should all be accepted for changing a password on the server. To achieve this I want write an "expect" script ...
0
votes
0answers
17 views

suming numbers one by one contained in a file until certain number and printing then

I have a file called temp6.dat with a list of numbers in a column. I want to sum this numbers one by one until the result is >=80 or <=85 and print the numbers from this list starting with the ...
-3
votes
0answers
27 views

Which project I should do [on hold]

Which Project can I do during my 15 day vocation In shell scripting and in combination with python for Debian distribution
2
votes
1answer
27 views

Is there a way to restart acpid on reboot?

I've installed a package called thinkpad-scripts. Simply put its a bunch of scripts that activate various functionalities on thinkpad devices on linux that wouldn't work out of the box on fresh ...
0
votes
0answers
24 views

Getting error while running the shell script

CURRTIME=$(perl -e ' print time(), "\n"') FILETIME=$(cat timestamp.txt ) TIMEDIFF=$(($CURRTIME - $FILETIME)) I need to add 1 second to FILETIME variable, even if there is no entry in timestamp.txt, ...
-1
votes
1answer
28 views

Bash Logical operation into variable

Easy one for you. Can we do something like this in Bash, without using IF statements? a=0 b=0 c=1 result= [ a || b || c ] # result of binary operation should be 1 Is this possible?
0
votes
0answers
9 views

Take similarly named fastq files on a folder and amke them input for an script(on pairs)

I have a set of files named like this inside a folder: AM11_BW415_R1.fastq.gz NAM13_BW968_R2.fastq.gz NAM17_AC_Barrie_R1.fastq.gz NAM3_PI648600_R2.fastq.gz NAM7_Glenlea_R1.fastq.gz ...
1
vote
1answer
21 views

How to get list packages installed in debian instance as an offline install for another machine

I have put together a debian instance with apt as the package manager that has many packages installed. I would like to install these same packages on another system that does not have an internet ...
1
vote
4answers
37 views

Converting for loops on script that is called by another script into GNU parallel commands

Currently I have the following script for using the HaploTypeCaller program on my Unix system on a repeatable environment I created: #!/bin/bash #parallel call SNPs with chromosomes by GATK for i in ...
0
votes
3answers
33 views

Replace and increment a line in bash

How can I read, increment and replace a value in a file? foo="val" ver="1.2.0001" ... Now I would like to increment the "0001" to 0002".
1
vote
1answer
39 views

How do I get the amount of internet data used throughout the day?

I need to set a cap to my internet usage and manage data usage to download things programmatically based on the amount of data I have consumed. Is there a way to find out how much internet data I ...
1
vote
1answer
54 views

System service “Error: Unable to initialize GTK+, is DISPLAY set properly?”

/home/matthew/@/Sync/FreeFileSync "/home/matthew/@/Sync/Backup.ffs_batch" If I manually run the above, it works, but it doesn't if I run it via the following service: matthew@matthew-pc:~$ cat /lib/...
2
votes
2answers
68 views

Sorting and editing a text file to output a new file

There are few stages to this problem. I have the following data and I want to sort it first on column 2 the 5 then 1. Then I would like to combine columns 5 and 6 together with a deliminator. When ...
1
vote
1answer
17 views

Permission Denied with running custom script that has correct permissions

I have downloaded script called 'linkhandler' in my /bin/ folder, whose content is below. I have given the file permissions, this is the output from ls -lah: -rwxrwxrwx 1 root 861 Jul 8 13:12 ...
-1
votes
2answers
48 views

Renaming file from a script? [duplicate]

I am creating a script which would enable me do something in a shorter amount of time. Is there a way that I can rename a file automatically from: WDMyCloud_plexmediaserver_1.16.1.1291.bin(07082019)' ...
0
votes
0answers
29 views

How to portably test for a SIGPIPE failure

In a bash script, I have a pipeline of this form /bin/find ... | grep --quiet --max-count=1 . Basically, I am just testing, yes/no, whether /bin/find found anything. Therefore, if /bin/find fails ...
0
votes
0answers
37 views

Why can't execute ls or cp commands with a variable as an argument [duplicate]

I am debugging a bash script. It executes cp and mv commands in the script when a variable containing a path is used as the argument to the command. I have duplicated it in the terminal as follows: ...
0
votes
1answer
37 views

crontab and scp file transfer via script

I have a script that exports logs from log management server and send those exports to the archiver server. When I run this script manually, it complete it's task without any problem. It download ...
1
vote
1answer
18 views

How to avoid prompts with install linux-image-extra-virtual

When trying to install linux-image-extra-virtual I get the usual prompt about /boot/grub/menu.lst being modified: What would you like to do about it ? Your options are: install the package ...
1
vote
1answer
28 views

How do I make the system wait for an script inside of my script to finish its background processes

I am building the pipeline for a set of data and what I have for the main part is something like this #! /bin/bash time bwa mem -o bwa/mem/Stettler -M -t 96 -R "@RG\tID:Test\tSM:Stettler\tLB:...
0
votes
1answer
32 views

Shell script cp command to a folder that will constantly change name

I have a script that downloads a folder. The folder has a fixed name with an ever changing number as a suffix, e.g. fixed_name_450. Each time I run to script the downloaded folder will have a new ...
0
votes
0answers
31 views

How can i get the incoming and outgoing traffic from ifconfig?

I am trying to get the incoming and outgoing traffic of my machine from ifconfig...As of my understanding Rx( total number of packets received) and Tx(total number of packets transmitted). But this ...
1
vote
0answers
48 views

Running hashcat periodically [closed]

How can I run hashcat to find md5-hashes? My Ubuntu shuts down the computation if the GPU has too high temperature. Is there way to write a script that if temperature is too high, hashcat saves ...
-2
votes
2answers
42 views

Perl::Find a substring and display a whole word

I have a text file that has some data like: PADHOGOA1 IOP055_VINREG5_1 ( .IO(VINREG5_1), .MONI(), .MON_D(px_IOP055_VINREG5_1_MON_D), .R0T(px_IOP054_VINREG5_0_R0T), .IO1() ); PADV30MA0 ...
-1
votes
1answer
37 views

Choosing best directories to compress and save disk space

What's the best way to estimate the compression level that can be achieved for a directory without storing the compressed files? I have a large amount of directories and sub-directories with files ...
0
votes
0answers
25 views

Why does fdisk sometimes ask what kind of partition to make and sometimes not?

Today I was trying to write a script for partitioning disks using fdisk (since that seemed like the simplest option). When going through fdisk the first time and pressing n for new partition, the ...
0
votes
1answer
33 views

problem with dynamic variable on a bash script

I would like to obtain a .txt file of the following format: chr1: 3 chr2: 3 chr3: 3 I use the following script but give different errors: #!/bin/bash touch number_samples.txt for i in {10..22} do ...
2
votes
1answer
36 views

Tool/script that can expand all 'include' directives in a makefile

Let us say we have the following Makefile include config.mk # Generate summary table. results.txt : $(ZIPF_SRC) isles.dat abyss.dat last.dat $(ZIPF_EXE) *.dat > $@ # Count words. .PHONY : ...
1
vote
3answers
104 views

Perl: Inserting at nth position in file

I have content in my file : 123456789 My output is: 1234CC789 Desired Output is: 1234CC56789 I am insert PP at nth position suppose. But when I am inserting any text it is inserting the text at ...
0
votes
4answers
38 views

Replacing several characters with newline

I have a file with data that looks like this: 0.5, 14, 14, 12, 1.000000736101224E-11, -- 0.5, 14, 14, 14, 9.999999999999996E-12, How can I replace , -- with a newline? I tried sed 's/,\ --/\n/' but ...
0
votes
2answers
44 views

REGEX: flush a number of related chains in iptables

I want to flush a number of related chains in IPtables. Their names like 'f2b.*' I want the entire chain gone! e.g. all this gone. -A f2b-postfix-sasl -s 103.231.139.130/32 -j REJECT --reject-with ...
0
votes
1answer
25 views

Split and store in Perl

I have a file with this content: Ref BBPin r:/WORK/M375FS/HMLSBLK4BIT0P0_0/LSVCC15 Impl BBPin i:/WORK/M375FS/HMLSBLK4BIT0P0_0/LSVCC15 Ref BBPin r:/WORK/HMLSBLK4BIT0P0_0/LSVCC3 Impl ...
0
votes
1answer
24 views

youtube-dl : how to skip downloads lower than 480p resolution?

When using the popular program youtube-dl, how can I skip download of certain videos, particularly ones that have a lower quality than 480p resolution?
0
votes
0answers
35 views

Script - Write stdout and stderr to a file AND to the terminal without pipe [duplicate]

I don't know if it's possible, I would like start a bash script without pipe which write everything to a file and at the same time see the output on the terminal. So I know how to do that with this ...
1
vote
0answers
19 views

systemd service start after network online and time synced

I made a system service for a python script, I want it starts on boot after the server is online and the time is synced correctly. What do I have to add in .service file? I tried in [Unit] with ...
1
vote
1answer
35 views

How to preserve filename and folder structure when using foremost recovery program?

I am desperately needing to run the linux recovery software foremost and preserve filenames and folder structure. As you might know the program renames the recovered files with a numerical value and ...
0
votes
0answers
22 views

check file of sftp and return output to log

I need your assistance. I'm trying to finish a script that I've done but it is not working perfectly. here is the script: #!/bin/bash # iclog=log key="keys/cash_prod_key" date=$(date +%Y%m%d) ...
0
votes
1answer
36 views

Reading commands from a file

I have saved the commands in a file and trying to read it from another file. commands without a pipe are working fine but wherever there is a pipe in command it is not getting executed. can anyone ...
0
votes
0answers
21 views

overwrite DNS domain

We have an enum server that sends all naptr request to an enum provider. The provider only responds back if the domain matches them. We have several domains and I need to intercept the request ...
0
votes
1answer
20 views

Expanding FEH capabilities to preview RAW files

I would like to preview RAW files in FEH. I now I can do the following nufraw-batch --embedded-image DSC_0151.NEF --output=- | feh - which opens the image in feh, but only works on one image at a ...
0
votes
1answer
28 views

csh: Changing path in non-interactive login

I want this: $ ssh nopathcsh@lo 'echo $path' /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games To return this: /usr/bin /bin I have tried changing and ...
0
votes
0answers
12 views

i3lock called by the i3-nagbar starts in the background

I am trying to set up a lock script with the i3⁻nagbar command. The current code i have: i3-nagbar -b "lock" "i3lock" -b "shutdown" "shutdown -h 0" And while the shutdown button works, the lock ...
0
votes
0answers
50 views

Strange counting problem of variable in bash script [duplicate]

I have the following bash script which works fine until I get to number 9 (/dev/sdj) where it does not produce the expected output. hdd1="$(sudo fdisk -l | grep "Disk /dev/sd" | awk '{print$2}' | sed ...
1
vote
2answers
54 views

Problem with while function in AWK script

I have a pretty ugly looking script that I use to process evaluation files from simulations, it looks horrible and no I am not a coder, though it usually works, however it is currently not. Just to ...
1
vote
2answers
37 views

Bash script is breaking after Continue statement

Here I'm trying to ssh to multiple servers remotely and check whether any processes running on those servers and wait until the process to get finished. while read ip name do process=alive while [...
0
votes
0answers
7 views

Launch Openbox actions through script or cli

I was wondering if it is possible to run openbox actions, like the ones that can be found on rc.xml like MoveResizeTo , through a console command so I can launch it from terminal or inside a bash ...