Skip to content
Advertisement

Tag: shell

if condition implementation in linux shell script

I have a list of 100+ folders in a linux at a folder path “files/data” where I already have basic script “list.sh”. When I run it… It is listing all the 100+ folders (amazon, apple, cola, pepsi, and etc…) in side the “files/data” folder. But I am looking for some if command implementation to achieve the bellow. When I call…

Copying folders but not tar files in linux

I have a folder, which consists of many folders and many tar files. (this many is around 1000) I want to write a script to copy all folders with their contents to another directory, but I do not want to copy tar files. I already know by writing cp -a /source/ /path/ I can copy a directory with its contents

Merge two files using awk in linux

I have a 1.txt file: A 2.txt file: FS for 1.txt is “||o||” and for 2.txt is “:” I want to merge two files in a single file result.txt based on the condition that the 3rd column of 1.txt must match with 1st column of 2.txt file and should be replaced by the 2nd column of 2.txt file. The expected

Send KillAll to multiple node process and wait response

I’m creating a script that makes some pull from a git repository. but first i want to send a SIGUSR1 to multiple nodes that i have running in the machine, and once all the procesess stop i will proceed to git pull so basicly i will run because my node is doing an infinite loop, i want to intercept this

Is it possible to set an alias for a string?

As I’m so lazy, I don’t want to type 192.168.1 everytime anymore. I tried this: root@kali:~# alias “ip” = “192.168.1” That does not seem to work. As an example off what I try to accomplish: I don’t want to type this anymore: root@kali:~# hping3 -S –scan 1-1000 192.168.1.133 But instead shorter: root@kali:~# hping3 -S –scan 1-1000 ip.133 Answer add ip=”192.168.1″

how to count repeated sentence in Shell

My expected result is like as below: I have found a way to deal with the issues, but my code is a little noisy. I was wondering if you could show me more high-efficiency way to achieve the goal.Thanks a lot. Answer If you’re lines are not already grouped, then you could use This will consume a lot of memory

Mac equivalent for find -printf

Is there a MacOS terminal equivalent to Mainly, I want to replicate the -printf behaviour on a Mac. Answer The unix command line tools Apple ships are terribly outdated; sometimes 12 or 15 years old. You can install find from Macports: That version of find has the -printf option.

Advertisement