Skip to content
Advertisement

Tag: bash

ls to list matches in specified directory

How do I list matched results in a specified directory? On my Ubuntu server if I list the contents of a directory it correctly lists it. My working directory is /var/crash. Let’s say I want to list all files that contain ‘tar’. In this example there should only be one match i.e. start.txt All’s good so far. However if I

cronjob does not execute a script that works fine standalone

I have my php script file in /var/www/html/dbsync/index.php. When cd /var/www/html/dbsync/ and run php index.php it works perfectly. I want to call PHP file through sh file, the location of SH file is as below This is the content of the dbsync.sh file is: When I cd /var/www/html/dbsync/ and run ./dbsync.sh it works perfectly as well. Now if I set

How to group by two fields using bash scripting?

Here is one example of one line of log: I know how to group by one filed, so this is the solution: and this would be results: My question is that how can I group by two fields instead of one, first should be $11 and second is $10? So results should change to: Answer how can I group by

Getting unexpected newline error while doing awk

I am running the following script in linux command line: I am getting the following error: I believe the quotes and spaces are consistent, but why am i still getting this error? Output of ps -ef | grep “java -Droute=full” Answer The actual problem you’re trying to solve is something like “How to kill the process whose command line contains

Multiple bash commands in background

I am trying to execute multiple single line commands in the background from php exec(). My script watermarks the video and deletes the original video and rename the watermarked video to the original name. I want to run the whole code in the background. I have tried both round () and curly {} braces but failed in the end below

How to keep 2 history files? One with timestamp, the other without

The reason I want to achieve this, is because I’d like to remove duplicates for easier command retrieval on the one hand, while still having the option of going over everything along with the timestamp, in case something bad happens, and perhaps going over what commands I executed can help somehow. Here is what I currently have, which doesn’t work

How to replace recursively part of file name in bash

I have a directory having subdirectories containing images files with a wrong name such like filename.jpg.jpg i want to replace this recursiveley with filename.jpg i have tried: or but none works thank you Answer If you have a rename utility which uses perl regular expressions, then use the below command :

Advertisement