Skip to main content

Questions tagged [shell-script]

Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

0 votes
2 answers
41 views

variable with hyphen in bash script

db1="community-service-data" db2="ecomm-data-test" drop_db="DROP DATABASE ${db1}" sudo -u postgres -S /bin/bash -c "psql -U postgres -d postgres -c \"${drop_db}...
CodeWeed's user avatar
  • 137
0 votes
2 answers
30 views

Bash script to compress nested directories not traversing correctly

I have a folder structure that looks like this: 0/1/2 and the numbers goes from {0..9} I tried writing a bash shell script so that I can compress each of the folders like this: #!/bin/bash for i in {0....
alpha754293's user avatar
0 votes
1 answer
40 views

Command not found on shell opening

Every time I open the shell, the first line on the terminal is "bash: n: command not found". I tried to look at /etc/profile, ~/.bashrc, ~/.profile and ~/.bash_profile but I was not able to ...
Alessandro's user avatar
0 votes
0 answers
23 views

Evaluate command inside comparison in makefile [duplicate]

I would like to check if Linux system is ubuntu inside Makefile. What I do is: copy_files: if [ "$(head -n 1 /etc/lsb-release | cut -d '=' -f2)" = "Ubuntu" ]; then \ ...
ellat's user avatar
  • 37
6 votes
1 answer
323 views

Why does redirecting stderr interfere with bash's handling of $COLUMNS and the `checkwinsize` option?

I'm scripting a testing framework in bash and am running into a weird situation. A couple things I'm doing in this post for illustration purposes: Adding echo lines to the scripts; these are not part ...
Targeloid's user avatar
  • 229
1 vote
2 answers
186 views

find with du -sch and very many files

I have large folder structure and need to get the size of a certain subset. The directories I need to count are defined by having specific subdirectories: find . \( -iname a -or ... \) -printf "\&...
cheersmate's user avatar
0 votes
0 answers
18 views

Setting variable (ORACLE_BASE) for oracle user | Installing Oracle 23

Goal: Install Oracle 23 into /u00/app (and not the default, /opt/oracle). Problem: Oracle installs into /opt/oracle (I assume the variable ORACLE_BASE etc. is not properly set / read for user oracle ...
DavidDunham's user avatar
0 votes
3 answers
51 views

xsel like a clipboard manager: keep clipboard content for future use

I'd like to run xsel as background process to keep clipboard content for future use. I run it in openbox startup script like that: xsel -b -k But when I select something with Ctrl-C and close ...
Anton Vakulenko's user avatar
3 votes
2 answers
294 views

Remove duplicates in file (without sorting!) leaving the _last_ of the occurences

Following https://www.baeldung.com/linux/history-remove-avoid-duplicates, I added clean_history() { awk '!a[$0]++' $HOME/.bash_history > $HOME/.bash_history.tmp && mv $HOME/....
Make42's user avatar
  • 697
0 votes
5 answers
107 views

To check whether first or last character of a string is x

I am trying to check whether the first or the last character of a string is x using zsh, and I get an error message instead: ./test.sh:2: bad substitution What is the problem here? string="2x3&...
jsx97's user avatar
  • 69
1 vote
1 answer
56 views

Grep return No such File, after comand substituion

I'm trying to use grep in a Bash script and assign the result to a variable: RESUlT=$(grep -R -I --exclude-dir=addons "^[^#]*print(" ) But it returns bash: Map/Places/place.gd:: No such ...
T.S's user avatar
  • 11
-1 votes
2 answers
171 views

Is it possible to translate bash to another human language like Arabic?

Bash commands are written in the Latin alphabet, is it possible to translate them to another language? In this case, Arabic. Arabic is written rtl and I remember I tried it using alias before when I ...
Abdelaziz Baheg's user avatar
0 votes
1 answer
82 views

How to make '.zshrc' to search for sourced files in the specific folder and not in the folder from which the terminal has been opened

macOS 14.5, Zsh 5.9. ls -A -- ~/: .zshrc system-wide-clipboard.zsh cat -- ~/.zshrc: autoload -Uz zmv alias zcp='zmv -C' alias zln='zmv -L' . ./system-wide-clipboard.zsh If I open the Terminal ...
jsx97's user avatar
  • 69
-1 votes
1 answer
56 views

Sourcing a shell script vs. Passing it as an argument to a shell interpreter [duplicate]

I'm new in shell scripting. As I discovered today, there are at least three ways to run a shell script: To execute it, using the absolute or a relative path: /folder1/folder2/script.sh ./script.sh ...
jsx97's user avatar
  • 69
0 votes
2 answers
59 views

In bash/zsh, how to compare the metadata in two directories including . and excluding .. and the contents inside subdirectories?

Let's say that in a script, you have a directory $1 and its copy $2 and you'd like to compare the metadata (names, permissions, sizes, full modification dates, …) of the files and directories inside ...
AlMa1r's user avatar
  • 174

15 30 50 per page
1
2 3 4 5
1099