Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
10 views

Script to add multiple routes in single machine for differnet virtual Nic

Script to add multiple ips for different NIC in single linux machine. For Example a linux machine having more than 50 nic like eth0 ,eth1,eth2,...eth50. This machine actually Virtual machine in ...
0
votes
0answers
20 views

Show Progress bar

#!/bin/bash cd /mnt/cloud/frozenfiles for index in $(ls -1) do echo $index:$(find $index -type f -mtime +273 | wc -l) done >> /tmp/cloud_files_over_273_days.txt This script removes files over ...
0
votes
1answer
29 views

Shell script which returns elapsed time, memory usage and CPU usage of executed script

I need to write a bash script which will be able to return elapsed time, RAM usage and CPU usage of executed script. my script: #!/bin/bash STARTTIME=$(date +%s%N) #here is script which needs to be ...
-2
votes
0answers
20 views

bash script to change lines in .cc file [on hold]

I need to create a script that can access specific variables in a .cc file and update their values. Can anyone send me any link that has info on how to perform such tasks on linux. My goal is to ...
0
votes
1answer
37 views

Is passwd file always in /etc/passwd?

So, I'm writing a script that needs to modify the such a file but from the partition of a non booted OS (for example from a livCD to a OS installed on another drive) and I was wondering if, given I ...
0
votes
2answers
34 views

Looking up IPs and writing to file in Bash

I'm trying to reverse lookup a list of hostnames to find their IPs and write to a file. I'm referring to this tutorial and expand on it to work with a list of hostnames. I'm new to Bash scripting and ...
-1
votes
1answer
28 views

Find Command, I want to use my variables

I have a script that creates a new directory based on User Input, and well as which directory contents it will copy over. Now here is where I am having issues, I have a find command that will replace ...
0
votes
0answers
20 views

Can I write a script to keypress ctrl z or ctrl c for me? What is /e[3J?

Hello I want a bash script that will stop other running scripts. I may prevent the scripts by renaming sudo and test for example but I was also wondering if a CTRL +Z loop would effect other terminal ...
7
votes
1answer
333 views

How to suppress a message from a program while installing it to use in a bash program? [duplicate]

PROBLEM: I have a program written in bash that does a lot of stuff like install new software on the system. One of the programs it installs has an extravagant message appear where you get some info ...
2
votes
1answer
41 views

How do you reuse a script in another?

Is it correct that there are two ways to reuse a script A in another script B: script B invokes script A as a command (B creates a child process to run A) organize the code in script A is organized ...
0
votes
0answers
37 views

bash script uses curl

sed -e 's/,$//' -e 'y/,/:/' test.txt | xargs -P 80 -I XX /usr/bin/curl -sk https://XX/ |grep phrase |printf "XX" it does not work for some reason. I need to do the curl and print the ip visited. The ...
-4
votes
1answer
62 views

How to move files that have a last access time 2 years ago

I need a script that moves all files I didn´t use 2 years ago in another directory. Currently i got this: find /sourcedirectory -maxdepth 1 -atime -700 -type f -exec mv "{}" /destination/directory/ \; ...
0
votes
3answers
550 views

Find how many times a certain DNA base sequence occurs in a file

The assignment is to write a bash script named “countmatches” that will display the number of times a certain sequence, such as aac, appears in a specified file. The script should expect at least two ...
-2
votes
1answer
47 views

Browse directory and extract word from folder name

I have the following list of folders having two words in name separate by a space WEB TEH COMPUTER SCIENCE UNIX LINUX I would create a shell script, this script can browse the directory and extract ...
0
votes
3answers
56 views

a script that takes a list of usernames and displays on the screen, for each user name, a formatted message using the “last” command [closed]

I have to write a bash script called "logincount" using the command "last" that takes a list of usernames as its command line arguments and displays on the screen, for each user name, a message in the ...
5
votes
1answer
101 views

Trying to understand how to work with IFS

I'm trying to understand how to work with the shell variable IFS. I have the following code: #!/bin/bash ourpath=$PATH oldIFS=$IFS IFS=":" echo "ourpath = $ourpath" for directory in "$ourpath"; do ...
4
votes
1answer
65 views

Pass variable to spawn [duplicate]

I want to pass server name which is listed in a file (servers_list) as variable to spawn command which is in another script (user_create_script). Purpose of this script is to create user(david) in ...
2
votes
1answer
44 views

Get web page from a list of ip addresses in a file

I have a list of ip addresses in a file, we can call that file ip.txt I scanned a subnet using zmap at port 80. So I have about 100 addresses returned into that file. Instead of popping each ip into ...
0
votes
5answers
101 views

How to get a count of variables passed to awk [closed]

I am trying to invoke awk inside a bash script and passing some bash variables values to it. Is there any way to get a count of these variables and print all which are passed to it inside awk. No. of ...
2
votes
5answers
37 views

How to store the full-path of a directory from a bash script?

I want to get the full-path director from a script, even if the user enters the './' or '/~' #!/bin/bash echo "Enter the directory" read DIRECTORY #how to store the full-path instead of something ...
2
votes
3answers
353 views

Bash Script to remotely collect hostname, IP and host total memory

I am trying to write a scrip that will collect the hostname, IP and total memory installed on remote hosts from a list I feed into the script. The script will collect information from Redhat and ...
0
votes
1answer
27 views

Replace values in a variable and retain new lines in BASH

This BASH script works as expected. I have a variable ($foo) that contains lines of data, I tell bash to separate at new lines, and I loop through the variable. #!/bin/bash foo=" Original Line1 ...
0
votes
3answers
35 views

Verify if a URL exists

I would like to verify if a URL exists without downloading. I am using below with curl: if [[ $(curl ftp://ftp.somewhere.com/bigfile.gz) ]] 2>/dev/null; then echo "This page exists." else ...
9
votes
3answers
2k views

How to grep for unicode � in a bash script

if grep -q "�" out.txt then echo "working" else cat out.txt fi Basically, if the file "out.txt" contains "�" anywhere in the file I would like it to echo "working" AND if the ...
0
votes
2answers
35 views

Bash command that iterates throught folder and runs python script

i am trying to run linux command to run python script: for f in /mnt/data/service/fmriprep/geht/sub-P*; do (python 2_correlation.py -i "$f" -o /mnt/data/service/corr_graph/correlation_P*.csv ) my ...
0
votes
1answer
124 views

How to set the background color of the Linux console screen?

Note: I reworked the question to clarify the issues. This is a trivial question that can be answered in several parts because the question has several attributes. Unfortunately, the question may be ...
0
votes
3answers
52 views

compare two IP address using bc

I am trying to compare two IP address using bc command however the IP with lower numeric value is not being trapped in the test. Here is my code: TEST=$(echo "$i < $IP_BRD && $i > $...
0
votes
2answers
52 views

Insert block of text in file [duplicate]

I am editing an Arch base installation script. I almost got it to work as I wanted! I need to add the following into the end of /etc/pacman.conf [archlinuxfr] SigLevel = Never Server = http://repo....
3
votes
3answers
113 views

Random mutagenesis with bash

I have a string e.g. 1234567890 and I want to replace random positions of that string with corresponding position from a random sequence in another set of other strings e.g. ABCDEFGHIJ KLMNOPQRST ...
1
vote
4answers
72 views

Merging text files and adding separator

I want to add a separator like this "==============" and a blank new line I tried to do this, but failed and causes high CPU usage. i mean the cpu become rotate ery fast and noisy when i run the ...
0
votes
0answers
11 views

Slackbuild script with “set -e” exit..at no error!

With this slackbuild myslackbuild I compile with sudo sh *ld and...it exit after the make even with no errors(!) after the line make install DESTDIR=$PKG If I remove set -e,continue and ...
1
vote
1answer
78 views

Adjust columns in a table

I have this table which is messed up DB Size_in_MB foobar 11011.2 barfoo 4582.9 donkey 4220.8 shoryuken 555.9 hadouken 220.0 kong 214.8 super_mario_bros_p 211.1 there are unnecessary ...
0
votes
2answers
26 views

Inputting data from a file into a label

I have file contains gigantic data about users. For example: Username:Firstname:Lastname:Telephone number Username:John:anderson:857-201-2213 Username:Sam:Asper:876-590-8223 Username:Adam:marlen:871-...
0
votes
2answers
26 views

Using Cut inside a script to cut a column from a specific String

I have this file called viagens.txt: 2018-10-01:88020:88013:6:4.2 2018-10-01:88020:88014:8:3.8 I want to create a script that, in each line, checks the second column (in this case, in both cases it ...
1
vote
2answers
34 views

Printing a dynamic list of month days vertically

I need to write few line in a code that I use in my study, and I really gave up! currently, i can list the days of a month and the equivalent day number but I can't link this to the system clock so it ...
0
votes
1answer
33 views

Fetching title of browser

[Fetching user title] Seen a post prior of someone posting how to do it by single account I wish to do this from the range 1-1000 and have it output to >> .txt Example: x@nine:~# wget -qO- 'http:...
0
votes
3answers
36 views

Bash: inserting output from `id` into print statement

I'm trying to achieve the following: List my Linux users, that have set bin/bash in /etc/passwd AND append each user's info from id [username] into the print statement, something in the lines of: cat ...
-1
votes
2answers
28 views

Wish to add numbers to word/url

What i want; as of example- Youtube.com/1 i wish to have an automated script that counts up to a 1000 URL EXAMPLE: https://www.youtube.com/1 https://www.youtube.com/2 Edit: --- [Fetching ...
1
vote
1answer
30 views

Using exec 1>&2 in a POSIX shell script function. Will it interfere with other io-redirects?

I am in process of writing a POSIX shell script. I have one function, which redirects (almost) all output to standard error stream like that: # print something to stderr printf "..." $var 1>&...
0
votes
6answers
71 views

while loop in shell script

I am able to run count command but when I use it in while condition, it is giving error: -bash: [/usr/bin/ps -aef|/usr/bin/egrep 'catalina|java|wrapper-linux-x86-64'|/usr/bin/grep -v 'catalina|java|...
0
votes
0answers
14 views

tcsh tab auto completion to match the MIDDLE part of the file name in the folder?

I have searched through google and So, while there is no hit for the auto completion function for tcsh that can do something similar to zsh that: when doing 'cd' or 'ls' you can match the MIDDLE ...
0
votes
1answer
34 views

File copy and and increment (iterate) 10000 times

I have unix file name - 1241241231.txt i have to copy and rename with increment counter til 10000, but file name should be of of 10 digits only. example: so i have to make copies like 1241241231....
0
votes
4answers
57 views

How to concatenate several text files with a blank line in-between each? [duplicate]

I am writing a shell script, and in that I am using three html files. Now I am trying to concatenate all three files, and send the content as an email to my self. Please see below what I am trying ...
1
vote
5answers
48 views

Delete the oldest folder from a path with an exclusion

I referred the following thread How to delete the oldest directory in a given directory? and the accepted solution is perfect. However, I have a requirement to exempt one folder that is the oldest. ...
1
vote
1answer
33 views

Optional commands for bash script

I have a Bash script that sets various environment variables and runs a program. I want one of those variables to change if I run the command with an argument debug. I know 100% how to do this in Lua ...
0
votes
2answers
39 views

Convert binary strings into decimal

I want to process with a bash script a text file that looks like this: ADD $05 $05 $05 SUBI $06 $06 00011 MUL $07 $07 $07 JSR 011101 taking the binary numbers (that are always ...
-1
votes
1answer
56 views

Converting csv file (generated by db query) to html and color code the table based on Column Value

(Using Shell Script) Need to generate html report from a CSV file which is an output of a DB query and then color code it based on column values. For example, from the given CSV ile, if any cell under ...
0
votes
1answer
34 views

How does redirection work between arguments

Given a command like this: command <inputfile> <outputfile> And then called like this: command FileA > FileC FileB It takes A and B as input and outputs to C, but how can it parse ...
1
vote
4answers
85 views

Having regex in Bash script

The bash script does many things. However, at beginning it should start if the input passed to the script is a directory path. For example, right way of telling directory path is "/var/lib/test", and ...
0
votes
0answers
15 views

Create a bind to toggle between a command and another with just one key press

Heelo! I am using ncmpcpp on a notebook that has i3-gaps on it and the keyboard have only one key to play and pause music but the XF86 commands only allow to send one command at a time (XF86AudioPlay/...