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…
Tag: shell
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
Inconsistent behavior when replacing substring with tilde “~” in a BASH parameter expansion
I came across some strangely inconsistent behavior in BASH parameter expansions across a few different servers, while trying to write a quick function. On some versions of BASH, to use a tilde in a substring replacement, the tilde must be escaped, or it will be re-expanded to the home directory: while on other systems, it will not be re-expanded, and
Can I run docker diff from a container on the same host as the container I want to run the diff on?
I have two containers running on a host. When I’m in container A I want to run a diff on container B compared to it’s image to see what has changed in the filesystem. I know this can be ran easily from the host itself, but I’m wondering is there any way of doing this from inside container A, to
How to pass run time arguments to a function in c through a shell script
I have a shell script which has to take arguments from the command line and pass it to a function in C. I tried to search but didn’t find understandable solutions. Kindly help me out. Should the arguments be passed via an option as a command in the shell script? I have a main function like this: How to pass
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.