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
0
votes
0answers
27 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
31 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
10 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
35 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
45 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
46 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
41 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
128 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
28 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
51 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
31 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
38 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
53 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
24 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
30 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
35 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
32 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
49 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
40 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
26 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
39 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
108 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
48 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
53 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
26 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
25 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
39 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
22 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
53 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
25 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
37 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
22 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
24 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
29 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
1answer
19 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
51 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
58 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
38 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
14 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 ...
0
votes
0answers
19 views

arch linux udev script trigger

I am looking for some support with an issue I have come across today. What I am trying to do: I am trying to use udev rules to trigger a python script which does multiple things including making a ...
1
vote
0answers
28 views

Run bash script as application, such as a Desktop icon does [duplicate]

What I can I do to execute bash script as application like open the "Desktop icon". Any idea for where can I start?
0
votes
2answers
58 views

Single text file: Compare the first n characters of each line and the next. If they are equal print the longer of the two in output file

I am using the Ubuntu bash. My file contains paths from a filesystem. E.g. C:\users\username\subfolder\thisismyfile.txt C:\users\username\subfolder\thisismyfileplusadate.txt C:\users\username\...
0
votes
2answers
37 views

Returning wrong results in perl script [duplicate]

I am running this command on linux shell it works smoothly sed -i 's/\[-.*-]//g' error .txt What it does is it removes patterns like [-any text-] along with the brackets and - sign. but when I try ...
0
votes
3answers
88 views

perl regex - How to match foobar that does not begin with (\s*//\s*)

Basically I want to find foobar on uncommented lines like: // foobar # do not match me foobar # match me otherfoobar # do not match me To match the commented lines I use this: ^(\s*//...
0
votes
2answers
38 views

Group Together Items By Consecutive Number

I have a series of files that look like the below, I need to group them into "consecutive groups", each line starts with a number, the file should be read from top to bottom, and if the next line ...
1
vote
0answers
33 views

What is difference between `` and $() for command-substitution in bash scripting? [duplicate]

I'm new to Linux and StackExchange. My English is pretty bad, and I'm sorry for mistakes. What is the differences between `` and $()? Does it matter what to use and when? I'll be grateful for ...
1
vote
1answer
39 views

getopts in function that is called more than once in a script, getopts doesn't detect any opts after 1st function call [duplicate]

I have read the getopts man page and am still not sure about this use case. getopts is not detecting any available options the second time a function is called in the same script. As you can see ...