Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 123460

Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.). Check scripts with https://shellcheck.net before posting.

1 vote

Using df -h, i need to create an bash script that displays anything about 60% utilization

df -h | grep '[6-9][0-9]%\|100%' will grep anything with 60% or more usage
FelixJN's user avatar
  • 14.1k
0 votes

Shell script to count the number of different vowels in a text file

Pure awk-solution for each vowel separately. #define array vowels with one vowel for each index BEGIN{ split("aeiou",vowels,"") } #in each line, make line lowercase {$0=tolower($0) #for each vowel oc …
FelixJN's user avatar
  • 14.1k
1 vote

how to redirect multiline bash command into a variable

A possible alternative could be a simple expect script: #!/usr/bin/expect spawn bluetoothctl send "scan on\r" sleep 10 send "quit \r" expect eof \r equals "Return / pressing enter". Make execut …
FelixJN's user avatar
  • 14.1k
2 votes

Comparing floats with an if-else statement in a shell script

First of all: bash can only handle integer numbers. So you need to make use of an external too for the floating point comparison. A simple way would be using bc, which outputs 0 on FALSE statements, a …
FelixJN's user avatar
  • 14.1k
3 votes
1 answer
2k views

Understanding backgrounded variable assignments and the wait command

In man bash it says: wait [-fn] [id ...] Wait for each specified child process and return its termination status. Each id may be a process ID or a job specification; if a job spec is given, all proc …
FelixJN's user avatar
  • 14.1k
4 votes

Compare portions of files

With dd Extract parts by skipping blocks. dd bs=32 count=1 skip=1 if=file5 | diff - file2 Increase the number of skipped blocks accordingly to match the other files. With split The files are sma …
FelixJN's user avatar
  • 14.1k
0 votes

How to sum column values for each row in two csv files using bash script?

for avoiding an intermediate file, use: paste <( awk -F, '{ print $8 }' original_file1 ) <( awk -F, '{ print $8 }' original_file2 ) | awk '{print $1+$2}' > file3
FelixJN's user avatar
  • 14.1k
0 votes

awk edit column value if numeric

using sed sed 's/^[0-9]/chr&/' file
FelixJN's user avatar
  • 14.1k
3 votes
Accepted

How to extract a string from a file name?

With bash you can do as follows: #!/bin/bash #let's look for an a in our handful of files string="a" for file in aa ab bb cc dd ad ; do #note the placement of the asterisks and the quotes #do not …
FelixJN's user avatar
  • 14.1k
1 vote

Simple bash script is not working

The read command takes the variable, but you already are referring to the values of the variable: #correct syntax read variable #wrong syntax read $variable $variable is the value of variable a …
FelixJN's user avatar
  • 14.1k
0 votes

Write file with 2 columns using shell script

Maybe a combination of paste and seq can be simpler: paste datafile <( seq 0 50 $(( ($(wc -l datafile | cut -d' ' -f1 )-1)*50 )) ) > output The last value for seq is just based on the line numbers …
FelixJN's user avatar
  • 14.1k
3 votes

how do I change just one character in a string when there more than one of that character?

GNU sed allows specifying which occurence of a pattern (in a line) should be replaced: First (default) echo AAAAA | sed 's/A/X/' XAAAA All echo AAAAA | sed 's/A/X/g' XXXXX i-th echo AAAAA | se …
FelixJN's user avatar
  • 14.1k
1 vote

list down files without extensions files on both sides in bash shell but keep original files

I assume rename (perl-rename on some systems, just rename on others) is simplest here: rename 's/^awstats\.//;s/\.conf$//' awstats.*.conf Explanation of the regex: s/^awstats\.// substitute awsta …
FelixJN's user avatar
  • 14.1k
0 votes

How to check if line is in the following format X.X.X.X

You could use the [[:alnum:]] class that stands for letters and digits: $p =~ ^[[:alnum:]]+\.[[:alnum:]]+\.[[:alnum:]]+\.[[:alnum:]]+$
FelixJN's user avatar
  • 14.1k
4 votes
Accepted

Need help comparing Strings with different sizes

I think you are better off using grep and GetLocalCit as list of search strings: grep -f GetLocalCit GetLocalNurse Or if they are commands rather than files grep -f <(GetLocalCit) <(GetLocalNurse) …
FelixJN's user avatar
  • 14.1k

1
2 3 4 5 6
15 30 50 per page