Skip to content

Tag: bash

How to print file/directory details using ls and AWK?

I am trying to print the output as below using the command: or But it does not print anything. O/P should be like, (I am using 0777 or 777 because of find . -type f -perm 0777) Answer you’ve got the right idea, but 777 is the octal representation of permissions, and with this you’re looking at the…

Is there a bug in “zgrep -H”?

Just tried grep and zgrep on following test file: I also need the file-name printed, so I’ve added the -H switch and stepped on the following problem: E.g. depending on POSITION of -H switch in the command-line – the behavior is different for me and the issue always reproduces 🙁 One more test: Her…

Bash: multiple redirection

Early in a script, I see this: And later: My understanding of this looks something like this: Create fd 3 Redirect fd 3 output to stderr (Upon app execution) redirect stdout to fd 3, then redirect stderr to stdout Isn’t that some kind of circular madness? 3>stderr>stdout>3>etc? I’m esp…

sbrk system call in unix

I studied like malloc uses the sbrk system call. But, some one says, the sbrk is deprecated one. Now a days malloc using the mmap2 system call to allocate memory. So, Is there any commands like (ls,cat, grep, sed) using the sbrk system call. For Ex: The above output shows that the ls command using the above s…

for loop syntax with grep in bash

I want to do text processing for lines in file.txt that ends with 0, I wrote an easy form of it to ask my question clearly. I want the output to be: 1 343 4352 0 432 432 2345 0 I want $i variable to be “1 343 4352 0” and after that to be “432 432 2345 0” but

Bash Array not accepting WildCard

I have an Array that I have setup in a bash script. My goal is to ping through a particular port on a a server with many network interfaces. For example the ping -I eth3 172.26.0.1 command to force ping through eth3 When I setup a bash Array I can get code to work if I call the Elements (ports)