I need to use some vars in a script where I use tail and head, my script works when I type it in the terminal but when it is in a .sh file I get this error from the head command: The error comes from this pipe of my script: I tried using variables in another script where only declaring
Tag: linux
linux command to delete the last column of csv
How can I write a linux command to delete the last column of tab-delimited csv? Example input aaa bbb ccc ddd 111 222 333 444 Expected output aaa bbb ccc 111 222 333 Answer It is easy to remove the fist field instead of the last. So we reverse the content, remove the first field, and then revers it again.
Yii2 call the console command not from the project folder
Hello. I created the console command in Yii2: I want to call this command in cron,and for testing I try to call it from the console, when I’m in the project folder: Everything works fine. But, if I call this command when I’m in a different directory, I get some errors. First, i got Seeing this, I …
How to use cron on a simple script
I want to use cron for execute a script periodically. I want to try a simple script first but it does not work. This is my script (scritp.sh) which permission are 700: And this is the crontab file when I edit it with the command crontab -e: EDIT: I have that script on /home/padro/Documents folder. What I do a…
How to sort or rearrange numbers from multiple column into multiple row [fixed into 4 columns]?
I have 1 text file, which is test1.txt. text1.txt contain as following: Input: Condition: A1 and B1 -> for each A1 + (B1 + [Tn + Vn]) A1 should be in 1 column. B1 should be in 1 column. T1,T2,T3 and T4 should be in 1 column. V1,V2,V3 and V4 should be in 1 column. How do I sort it
linux find files with optional character in their name
suppose I have two files: ac and abc. I want to find a regex to match both files. Normally I would expect the following regex to work, but it never does: I have tried escaping or not the questionmark, this never seems to work. Normally in the regex documentations I have found; ? means: previous character repe…
Fail event on mdadm
I received this error: This is an automatically generated mail message from mdadm running on host.xx.xx A Fail event had been detected on md device /dev/md2. It could be related to component device /dev/sda2. Faithfully yours, etc. P.S. The /proc/mdstat file currently contains the following: unused devices: T…
find and delete command in linux returning exit status 1 after deleting files
I am working on a linux script in which i have to delete the directories which are created before 7days. I have found a command which does the same. Below is the command But when i am checking the exit status of the command using echo $? it is returning 1 even after deleting the files from the location. To
can FileOutputStream.flush() guarantee that other processes can read the file content consistently?
I have a java process A that calls FileOutputStream.flush() to flush the content, and have another process B to read the file content. In most cases, the process B reads the content fine. However, sometimes B reports getting incorrect content. My question is, if the writer process crashes right after calling …
Directory: Is a directory
I’ve set up a cron job to run a Python script to scrape some web pages. /etc/crontab However, the emails are informing me that… /bin/bash: /usr/bin: Is a directory When I manually run the script, it pipes data into my database, but when the cron job executes the script, nothing… What does th…