Skip to content

Tag: linux

Excluding a file extension through wildcards

I have a directory which files with multiple extensions such as *.asc, .txt..csv etc. I am using this path in a script where I can only change the file names, which is passed through variable. I can pick all the .csvs by passing *.csv as the variable value or *.txt for respective files. However what I want to…

Read battery status bluetooth headset linux

I use Bluetooth headset that use Bluetooth version 4.1. When I connect with android it shows the battery status. But with Linux (Ubuntu 18.04) I cannot get battery status. I tried with bluetoothctl, looking file in /sys/class/power_supply as in other questions, But they didn’t help me. askubuntu.com/que…

mail -s waiting for CTRL+D in bash script

I have this bash script to check if an nfs share is mounted but its hanging on waiting for CTRL+D to be pressed for the mail part when I run it – how do I get around this? Answer This is what every command which reads standard input will do if you do not provide it with standard input from

Comparing 2 files in c linux fgets

I need to compare 2 files and return 1 if they are same or 0 if not, but function always return 0. I have no idea why. Maybe you know diferent function that can do this. Answer strcmp(line1,line2)==0 means line1 and line2 are equals, your code supposes they are different There is an other error, if a file is …

Why isn’t this sed command working for the regex?

I want to remove the multi-line comments in Java using sed command. The regex is working if we use character ranges like a-zA-Z0-9 etc. but not in case of word character like wS. Test-File content: Command used : Expected results: Actual results: Answer You can use grep with a regex (-E) and inverted matches …