there are many of files in this directory: and i want to make a list which just contains those files which have the pattern of: to match the file names such like: how can I use regexp to achieve this goal? Maybe we can use this syntax: Answer In regexp land, many roads lead to rome. 🙂 ^ marks the
Tag: shell
How to run an Ansible task with become and the same $PATH?
I want to run this task but it fails since it does not find the bundle binary because the user I am running it with has a different $PATH in Ansible than when I just sudo su – deploy. If I SSH into the box as root and then run sudo su – deploy and echo ‘whoami’ $PATH I get
Can I use hexdump in a shell script?
Can I use hexdump in a shell script? When I use it I keep getting an error . syntax error near unexpected token ‘hexdump’ I am not able to figure out why the hexdump code is giving me an error . Please help . Answer You are missing the do in your for loop:
Why does posh fail to perform pathname expansion when a part of the path is specified within double-quotes?
Consider the following simple shell script: I get the expected output with bash, ksh, zsh and dash, but I don’t get it with posh: I am trying to understand if the behaviour of posh is correct as per the POSIX standard or if it is a bug. The relevant section in the POSIX documents seem to be “2.6 Word Expansion”:
Why does shell command “{ command1; command2: } &” open a subshell?
As we all know, placing a list of commands between curly braces causes the list to be executed in the current shell context. No subshell is created. But when using “&” after “{}”, why two subshells are created? pid 1002 and 1003. when using “./a.out &”, only a subshell is created. pid 17358. Why ? Answer Background execution of a
Incorrect format of sending mail from Linux shell
My file format is as below: But if I mail it to my mailbox, the format will be as below: How can I keep my original format when I send file content to my mailbox!? Answer The SMTP specification says that end-of-line in SMTP messages is where in Unix/Linux the end of line is Run the text though a tr
awk in non-interactive is leaving some data missing
I’m running an awk command in a shell script, and it’s breaking the datafile. All of the data doesn’t load, and there’s a newline character at the end of each line. If I run this as a command, it works perfectly. I’ve just found that i can use fflush() and it seems to have solved the issue. So now i
How to gather IP and User Agent info and uniq them base IP address from nginx access log with AWK?
i have a sample log file I want to collect all the ip and user agent info to a file, and uniq the same IP address, how can i do with awk ? output like: Answer With sed, sort and uniq :
Shell: How to move multiple files to a directory and zip that directory with different name?
Fore example, I have some files in my project, structure could be like this I want to zip some files from my project and I can do that using ZIP command (build folder and some other files are excluded from zip) After this new file is created: In Mac Finder when I double click on this file it becomes unzipped
Why does ksh fail to capture standard error during nested command substitutions?
I have the following shell script. It produces the following output in bash, zsh, dash and posh. It makes sense because there is no such command called bogus on the system. But in ksh on Debian, it does not print the error message due to invoking the bogus command. What went wrong? In case, you want to know about the