Skip to content

Tag: linux

Exec command in Ant only executes first command

I want to list the permission of every script in directory dir/bin. But the below command only runs “ls” in the directory where the script is with below code rather than every script in dir/bin. Since script.xml is there in maindir, it just does a ls inside maindir. There are 2 problems: Performin…

How to stop newline chars from escaping OLD gnu sed command

I am trying to replace a line in a file with multiple lines. When I had only one new line char ( ‘$’n ). it worked fine, however when I use two of them, it escapes my sed and the file wont run anymore. File.txt: DesiredOutput Actual Output Answer Using older BSD sed you can do: This should work wi…

Status after each argument passed to -exec in find

I’m writing a quick script to list all the files in a directory, run a function on each of them, and then print out the status code. Now the status code I would like is of the entire transaction and not the last expression that was executed. For example… Let’s say I have the following files …

Extract desired information from a string in Linux

Below is the string that I get, now I want to extract the two 3840 from this line, what command should I be using in Bash scripting? Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840×3840 [SAR 1:1 DAR 1:1], 100072 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc Answer You can pipe i…

Executing a script from a parent directory?

I have a root directory. In there I have ./bin/ In ./bin/ I have some bash scripts like: These scripts must be ran from ./bin, that is, the working directory must be: however, I would like to do: That last line would set the working directory temporarily to ./bin/ and would execute my script found in ./bin an…

Dynamic library timing and CPU load analysis in linux

I am writing code with one dynamic library. When I used dlopen/dlsym calls to access library functions, cpu load and execution is more as compared to linking library dynamically using -l and accessing function directly. Can anyone help to understand why this is happening? Answer Static linking requires more t…

Running awk command in remote host fails

I am running a shell script to run awk command on a remote host. The awk command runs fine locally, but when run for the remote host fails (the redirected file is empty): Here is the script run on remote host: smb.conf.tmp is empty in remote host !! Locally: I followed this link for awk running on remote host…