Category "bash"

grep positive/negative integer value only

I am looking to grep any positive/negative integers only and no decimals, or any other variation including a number. I have a testpart1.txt which has: This is a

How to get latest file from sftp server to local using mget in linux?

Hi I am following below logic to get the latest file from sftp server. But it is copying all the files. Please help what I need to correct in my logic? datadir=

delete kubernetes pods which status shows 'CrashLoopBackOff' via shell script

I trying to write a script to delete pods status CrashLoopBackOff from all namespaces. #!/bin/bash # This script is basically check all avialble namespaces # a

BASH: Filter list of files by return value of another command

I have series of directories with (mostly) video files in them, say test1 1.mpg 2.avi 3.mpeg junk.sh test2 123.avi 432.avi 432.srt test3 asdf.m

Flickr camera roll backup with wget or curl

How can I backup the camera roll page in flickr with wget or curl as a static page? #!/bin/bash cookies=/Users/xxx/Downloads/flickr/cookies.txt root="https://w

Execute Openwrt UCI add_list through ubus call

I am trying to add a new interface to the network.lan.ifname using the "ubus call uci add_list .." The syntax used to run it directly is (which is working): u

Git alias for checkout branch, pull and checkout back

We are using the Feature-Branch-Workflow, which means others merge theire changes to the dev-branch that I want to merge into my feature branch. As it happens a

AWK return/print as associative arrays in Bash

With this command I am trying to filter through my firewall. In order to extract the firewall rule ID number and the IP address. existing=($(ufw status numbered

How schedule crontab job when using pyenv and pipenv

I'm on Ubuntu 20.04, and I am having issues setting up the crontab correctly using pyenv + pipenv together. Simply adding pipenv run python script.py to the cro

JQ map objects to array

I have this input data: [ { "attributes": { "created": "2021-10-18T12:02:39+00:00", "enabled": true, "expires": null, "notBefore":

How schedule crontab job when using pyenv and pipenv

I'm on Ubuntu 20.04, and I am having issues setting up the crontab correctly using pyenv + pipenv together. Simply adding pipenv run python script.py to the cro

How to keep dollar sign within sed in the bash script?

I am trying to find a way to escape the dollar sign within the sed command in a bash script. I have found here tons of answers that say that you need to put fou

How to read user interaction of rm -I command and store in a variable shell scripting

so this function basically runs similar to rm -i command and the arguments are passed while executing (eg. bash script_Name test.txt). rm -i $file does ask me t

Fixing PATH for Python libraries using Bash

I am attempting to install some Python libraries by executing variations of the following command in Bash: pip install --user -U numpy I installed Python3 usin

How to remove a single command from bash autocomplete

How do I remove a single "command" from Bash's auto complete command suggestions? I'm asking about the very first argument, the command, in auto complete, not a

Script to create swap partition fails when running automatically

I am creating a cluster of machines in AWS (Amazon Linux 2) using terraform by utilizing the user_data argument under the aws_instance resource. Part of the scr

Why assignment inside loop not influence the global value?

I have next data source and code: data: 1 2 3 test.sh: s=0 cat data | while read oneline do v=$(($oneline)) s=$(($s+$v)) echo $s done echo "Final:

Write a shell script to find the largest among three numbers. Get user inputs and display the result

Write a shell script to find the largest among three numbers. Get user inputs and display the result. Sample input 1: 10 20 30 Sample output 1: 30 is lar

sed replace backslash double quote with single quote

I would like to take the following: echo "'{\"apiVersion\":\"apps/v1\", \"kind\":\"two\"}'" And end up with the following via using SED: {'apiVersion':'apps/v1

Restart terminal without closing on MacOS

How to restart my current MacOS terminal session without closing the window? In Linux I use exec bash but it does not work in this environment. I made a few ch