bash

Find all the folders that are concealed using 'chflags'

Find all the folders that are concealed using 'chflags' I have concealed some folders on my laptop using chflags: chflags hidden hide-me And I don’t remember where exaclty these folders are located. How is it possible to find all of them? (Probably by using find and/or grep.) Asked By: jsx97 || Source Something like that: …

Total answers: 1

Odd inconsistency between executing and sourcing Bash script

Odd inconsistency between executing and sourcing Bash script I know this is not a very descriptive title (suggestions are welcome), but the fact is that I’ve been pulling my hair over this for hours and I have no clue where the root of the problem might lie. I wrote a simple Bash script for CLI …

Total answers: 1

What are some common uses for `run-parts`?

What are some common uses for `run-parts`? run-parts executes all programs and scripts in a directory — but when do I need it? What are some common uses for it? Asked By: PetaspeedBeaver || Source You’d mainly use run-parts when you’ve got a bunch of scripts in a directory that you want to execute all …

Total answers: 2

Should I put functions in .bashrc, .bash_aliases or .profile

Should I put functions in .bashrc, .bash_aliases or .profile I have read this thread about where to put aliases. Now, let’s suppose that my custom command is quite elaborate (takes arguments in input, is composed of several commands run one after the other, I want to preserve it multi-line for clarity’s sake, involves quotes, double …

Total answers: 2

Prevent command from running in zsh

Prevent command from running in zsh In bash I can do: #!/bin/bash validate() { if [[ "$BASH_COMMAND" == whoami ]]; then return 1 else return 0 fi } set -T trap ‘validate’ DEBUG shopt -s extdebug so that if I run whoami nothing happens. How can I achieve the same in zsh ? I’ve looked …

Total answers: 1

Difference between cp and cp -rf on a Mac

Difference between cp and cp -rf on a Mac Could anybody explain is there any difference between cp some-file.txt some-folder and cp -rf some-file.txt some-folder on a Mac? I was told that cp -rf forces cp to overwrite existing files, but it seems it overwrite them even without -rf. So what is the reason to …

Total answers: 1

custom bash prompt has leftovers from previous commands

How can I properly make a bash prompt with error colors and emoji? After solving the first issue with my custom prompt I still have another one left. When I cycle through my last used commands via the arrow-up and arrow-down keys I will sometimes have some characters from a previous command stay visible although …

Total answers: 1

Removing spaces between words in a text file using a bash script

Removing spaces between words in a text file using a bash script I am using a bash script that parses data from a bunch of different text files and generates a .dts file. The .dts file contains spaces between each column title and I need to remove them as it makes a plotting tool I …

Total answers: 2

How to hide command output, then run another command

How to hide command output, then run another command I have this command which may output an error, so I hide it using &>/dev/null. Now I would like to run this command, then run another command. This is what I have now: ( aaa &>/dev/null ) && bbb I’m expecting to see: Command ‘bb’ not …

Total answers: 1

How do I read the last lines of a huge log file?

How do I read the last lines of a huge log file? I have a log of 55GB in size. I tried: cat logfile.log | tail But this approach takes a lot of time. Is there any way to read huge files faster or any other approach? Asked By: Yi Qiang Ji || Source You …

Total answers: 4

I want to "Autocomplete" sub and sub/sub directories rooted in a fixed directory

I want to "Autocomplete" sub and sub/sub directories rooted in a fixed directory I have some directories with music files $ tree -d ~/Music/ /home/boffi/Music/ ├── Aldous_Harding │   ├── Aldous_Harding │   ├── Designer │   ├── Party │   └── Warm_Chris ├── Madness │   └── The_Very_Best └── Mitski ├── Be_the_Cowboy ├── Bury_Me_At_Makeout_Creek ├── Laurel_Hell ├── Lush ├── …

Total answers: 2

Bash parameter substitution with multi line error message

Bash parameter substitution with multi line error message I’m using parameter substitution with an error message, such as ${var1:?’some message’}. I’ve incorporated a multi-line error message. Presently, it only functions properly when enclosed within single quotes, with line breaks inserted using the Enter key. Is there a clever way to allow acceptance of multiple lines, …

Total answers: 1

How can I start a NPM app from a desktop shortcut?

How can I start a NPM app from a desktop shortcut? I have created a desktop shortcut for a npm application called TMXEditor, but it doesn’t work. I can launch the app if I do cd /home/souto/Apps/maxprograms/TMXEditor && npm start on a terminal. I put that in a bash file /home/souto/Apps/maxprograms/TMXEditor/start.sh. The application runs if …

Total answers: 1

changing bash output format results in strange behaviour

changing bash output format results in strange behaviour I already changed my bash output format to something like this: which I am very happy with. I achieved this by adding this code to the .bashrc: set_PS1() { local RESET=$(tput sgr0 ) local BOLD=$(tput bold ) local RED=$(tput setaf 1 ) local GREEN=$(tput setaf 2 ) …

Total answers: 1

Symbolic link to application – working directory

Symbolic link to application – working directory Lets say i have a bash script in a folder called Programming, which reads data from files in a subfolder named data. The paths in the script to the files are all relative to this "Programming" folder. echo "test" > ./data/test.txt. So the working directory should always be …

Total answers: 1

How to hide desktop from Ubuntu Desktop Applications UI

How to hide desktop from Ubuntu Desktop Applications UI I found the following link for changing file types application: https://superuser.com/questions/21626/ubuntu-change-the-default-program-used-to-open-a-type-of-file Here is the command for associating the file type "application/pdf" with the "kde-kpdf.desktop" : $xdg-mime query default application/pdf AdobeReader.desktop $xdg-mime default kde-kpdf.desktop application/pdf $xdg-mime query default application/pdf kde-kpdf.desktop I just want to double-click the "*.pdf" …

Total answers: 2

find with execdir, pipe redirection evaluated too early (quote issue?)

find with execdir, pipe redirection evaluated too early (quote issue?) I use multiple GitHub accounts at work, so I need to modify the remote url to add my work account. I have figured out the recursive find -execdir, and how to get/sed/set the remote url, but I cannot combine them. I tested the find command …

Total answers: 1

LINENO and BASH_LINENO

LINENO and BASH_LINENO So I’m not sure why this is.. I know ${LINENO} normally contains the line in the script, and BASH_LINENO goes based on input from BASH_SOURCE as an array $ (echo hi;declare -p LINENO BASH_LINENO;echo -e "My LINENOtist${LINENO}nMy BASH_LINENOtist${BASH_LINENO[@]}") hi declare — LINENO="34" declare -a BASH_LINENO=() My LINENO is 34 My BASH_LINENO is …

Total answers: 1

Restoring bash prompt $PS1 to default

Restoring bash prompt $PS1 to default Is there a bash shell script or command that I can invoke to restore the original value to $PS1? I clobbered it without making a backup copy. If need be, I can always re-install bash, I’m hoping there is a less drastic method. BTW, I’m using bash v5.2.26 Asked …

Total answers: 1