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…
Tag: linux
Add timestamp to R CMD BATCH outfile name
I want to run a script, and name the outfile. The default looks like this: How do I add a timestamp to the name? Something like this: Answer Couldn’t show backticks in the comments, see below:
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…
Confusion over compute units and expected cores on nvidia GPU
I have an nvidia GTX 750 Ti card, which is advertised as having 640 CUDA cores. Indeed, the nvidia settings application also reports this. I’m trying to use this card to do OpenCL development on Linux. Now, I have reported from the OpenCL environment (through PyOpenCL if it makes a difference) that the …
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…
What’s the purpose of `on_rq` field in `task_struct`?
I am now reading the source code of try_to_wake_up() function of Linux Kernel. This function does a lot and includes this: return p->on_rq == TASK_ON_RQ_QUEUED. So, what is the actually purpose of on_rq field in task_struct. BTW, does there exist some manuals or reading materials to introduce all the field…
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…