command

How do I get bash to use a specific directory when running a command?

How do I get bash to use a specific directory when running a command? I have a problem with the handling of the mysql command.  When I try to use mysql -uroot -p, I get an error: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) However, when I try to use ./mysql -uroot -p from /data/local/tool/mysql-5.6.21/bin, I can connect to …

Total answers: 2

How does the d option for the ls command exactly work?

How does the d option for the ls command exactly work? Having the following simple structure: project main aaa aaa test ddd ddd pom.xml <— unique regular file If the current directory is project and if is executed the ls command appears main pom.xml test Until here all is OK. Now, according with man ls …

Total answers: 3

Quote characters work as commands that redirect to the standard input

Quote characters work as commands that redirect to the standard input I am a student and I am trying an excercise that involves assigning a word with quotes, double quotes and other symbols to a file name. The problem is that I am not getting the expected results. I am using the scape bar to …

Total answers: 1

Find file in directories of PATH env which match partially

Find file in directories of PATH env which match partially Idea is to match a filename in any of directories mentioned in PATH environment. Usually, we do this by running "which <executable_filename>". This works fine, when the file your are searching matches exactly in any of directories in PATH. If file contains a "suffix", this …

Total answers: 1

How does the `tr` command work?

How does the `tr` command work? I was playing around with tr and got some unexpected results. What is happening in these situations? I don’t understand what is happening under the hood, or perhaps I’m not using this command correctly. Example A echo ‘0123456789’ | tr [:digit:] ’12’ 1222222222 Example B1 echo ‘1111111111’ | tr …

Total answers: 2

Command like head except instead of showing output by new line, shows output by space

Command like head except instead of showing output by new line, shows output by space head example: Desktop: λ df -h Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk1s7s1 113Gi 8.9Gi 8.6Gi 51% 355384 90345720 0% / /dev/disk1s2 113Gi 3.3Gi 8.6Gi 28% 1743 90345720 0% /System/Volumes/Preboot /dev/disk1s4 113Gi 24Ki 8.6Gi 1% 5 …

Total answers: 2

sticky bit on files and directories

sticky bit on files and directories I’ve always heard that sticky bit should be only used with directories, and I understand that, but what is the meaning if it is applied to a file. If I set the sticky bit to a file and do an ls -la I see a capital T, but I …

Total answers: 2

Command(s) to know If the current RAM installed by slot is ECC/Non-ECC and Buffered/Unbuffered

Command(s) to know If the current RAM installed by slot is ECC/Non-ECC and Buffered/Unbuffered About RAM for laptops I did realize that is available ECC Non-ECC Buffered Unbuffered It according with: Kingston Technology KVR16LS11/8 8GB 1600MHz DDR3L (PC3-12800) 1.35V Non-ECC CL11 SODIMM Intel Laptop Memory A-Tech 4GB DDR2 800MHz SODIMM PC2-6400 1.8V CL6 200-Pin Non-ECC …

Total answers: 1

When is useful use "silent" for tty?

When is useful use "silent" for tty? If the tty –help command is executed it shows tty –help Usage: tty [OPTION]… Print the file name of the terminal connected to standard input. -s, –silent, –quiet print nothing, only return an exit status –help display this help and exit –version output version information and exit Therefore …

Total answers: 1

Is there a tool to test if a date-time is in a given range?

Is there a tool to test if a date-time is in a given range? I need to develop a script to test if "now" (e.g. the output of date) is in a given range. For now, this range is expected to be a list of days of month (e.g. 10,11,12,13,21,22,23). And I could code that …

Total answers: 1

Does ssh run commands (rather than shell itself) in a login shell?

Does ssh run commands (rather than shell itself) in a login shell? According to man sshd: LOGIN PROCESS When a user successfully logs in, sshd does the following: <…> 9. Runs user’s shell or command. All commands are run under the user’s login shell as specified in the system password data‐ base. It is not …

Total answers: 2

Is `command -v program` always executable?

Is `command -v program` always executable? I am using the command -v "program" >/dev/null 2>&1 construct if I need to POSIX-ly find out if such program is installed in an if-statement. From its help page is not clear, whether it checks only for path or also for the executable bit? $ command –help command: command …

Total answers: 1

Linux Sleep Command – Sleep less than 1 ms

Linux Sleep Command – Sleep less than 1 ms How can I sleep less than 0.001s / 1ms? If I use this, it shows me that is is only sleeping for 1ms. Is it possible to sleep less? $ time sleep 0.00001 sleep 0.00001 0,00s user 0,00s system 79% cpu 0,002 total Asked By: Pixelbog …

Total answers: 1

Write directories, subdirectories and file names to .txt file

Write directories, subdirectories and file names to .txt file I am looking for a command that will write the names of all directories, subdirectories and file names to a text file. Example format: directory1 |_subdirectory1 | |_filename1.mp4 |_subdirectory2 | |_filename2.txt | |_filename3.jpg | directory2 | … So the text file will only just show what …

Total answers: 2

Creating & debug of a bash script menu

Creating & debug of a bash script menu I’ve tried a first time with sh like I refer to in my other post here. I’m trying to run a bash script menu to run from terminal only. #!/bin/bash HEIGHT=800 WIDTH=600 CHOICE_HEIGHT=8 BACKTITLE="Installer-menu" TITLE="Setup opions" MENU="Choose one of the following options:" OPTIONS=$(1 Add Mint PPA and …

Total answers: 1

How to create custom math command in Unix/Linux?

How to create custom math command in Unix/Linux? So, I want to make a factorial command for the linux terminal, and I want to be able to run it like this: $ factorial 5 120 However, when I look at questions about this, I only see commands that runs a SET of commands, like for …

Total answers: 1

How to print the failed command that caused the script's failure?

How to print the failed command that caused the script's failure? I’m using the -e flag. Usage: #!/bin/bash -e Explained: -e Exit immediately if a simple command (see SHELL GRAMMAR above) exits with a non-zero status When a command in the script fails, the script exits and doesn’t continue to execute the rest of the …

Total answers: 2