I want to compare current date to date present in file [every 30 seconds and in background] I don’t know if I have to do an infinite loop or a while read line loop … So, every match of current date with a date of a file, I print the current line matched in xmessage. ( I add a date
Tag: bash
output mountpoint on (usb)device detection
I want to create a bash script that will output the mount point from an inserted USB device. I have two commands (between “do” “and” done”) that work separately but not together in a bash script. The script looks for a UUID file use the $UUID filename in the lsblk command to extract the mountpoint The mount point must be
How to resize the block of a column
I have a single column of a file having many blocks and the blocks are separated by the > symbol. I want to resize all blocks to the same highest length by appending zero below them. My file is given below: file.txt and my expected output is given below I am trying to write a script, but it fails: Answer
Convert timestamp to date results in time out of range error
I`m trying to convert a timestamp to an ISO8601 datetime-string. E.g. The timestamp is fairly long, with nanoseconds precision, and when I use the full timestamp it returns the following error: date: time ‘1606982602015489365’ is out of range The expected result should be: 2020-12-03T09:03:22,015489300+01:00 When I cut the timestamp to this: 1606982612 the error is gone but I loose information!
Can someone help me to translate this line of code for bash shell?
I have been struggling to understand this line of code, could someone helpe me ? for what I understood the od means will convert the outout for octal format, -An I think it means input base which is no address but why ? and the -N is the length if someone could help to translate this while sintax I would
How to have Bash set -x only apply to the very next command without creating child processes and without calling set +x
This is limited to Bash only, and the answer needs to work on all Bash versions without exception. I do this now: and it does what I expect: The op1 is not transcribed, the op2 is transcribed, and then op3 is not. And this has the feature that if “code wedging” occurs whereby op2 has a lot of lines of
Can we store “cd ..” path in a variable in bash file?
I am new to the bash my use case is to store the one previous directory in to a variable. Example: How can we add /local/ to any variable like $PREV? Answer You can use parameter expansion on $PWD which contains the current path: Or, use an external tool like readlink with command substitution:
Bash: While-read loop skips the last line of comma-separated text file
I am trying to read some comma-separated data from a text file, parse it and calculate average of column-5. The input is in the following form: I am using the following script for this: The problem with the script is that it does not read / parse the last line of the text. What can I do about that? Also,
How can I find the number of 8 letter words that do not contain the letter “e”, using the grep command?
I want to find the number of 8 letter words that do not contain the letter “e” in a number of text files (*.txt). In the process I ran into two issues: my lack of understanding in quantifiers and how to exclude characters. I’m quite new to the Unix terminal, but this is what I have tried: I need to
Rounding of the millisecond part in Linux datetime
So I have the date format like this : 2019-10-19 23:55:42.797 and I want the millisecond part to be round of into the second so the output should look something like this: 2019-10-19 23:55:43 I have tried date -d “2019-10-19 23:55:42.797” “+%Y-%m-%d %H:%M:%S” but it’s giving me output like 2019-10-19 23:55:42 How should I do this in Linux bash shell?