New answers tagged

2

After searching for a while, it turns out the issue is caused by the writing the script in Windows env and trying to run it in Linux env. A super easy way to make it work is to use dos2unix (it can be easily installed by sudo apt install dos2unix) cd into the folder where you have the code, then dos2unit *.sh then run the ./install.sh


4

The program you are trying to run appears to be this FormReturn. If so, you likely need to edit formreturn.sh so that FRM_HOME points to the location of the script (likely /home/pedro/Formreturn – Note, no trailing slash). By default, it is set to . which won't work when the script is called from a launcher because the pwd may not be the same as the script ...


0

I have solved the problem by installing package printer-driver-gutenprint. This package has the majority of the older printer drivers. Go to the terminal (CTRL+ALT+T) and copy the following line: sudo apt-get install printer-driver-gutenprint


2

A simple rule of thumb is: if your script was written in bash, do not assume it will work in dash. A full list of differences is beyond the scope of a simple Q&A, but essentially, dash is a POSIX shell, so it implements what is described in the POSIX specification for the shell language and only that. Here are the common bashisms I most often fall afoul ...


0

I've since realised that the .sh file was executing - it was just the output that was not executing. I fixed this issue by adding SHELL=/usr/bin/bash to the top of my crontab, and by changing the relevant line to use &>> to output to a log file: * * * * * /home/josh/test_script.sh &>> /home/josh/cron_logs/test.log Credit to this answer - ...


1

It's not the definition that needs quoting, it's the variable expansion: Instead of: var='core show version';asterisk -rx $var like this: var='core show version';asterisk -rx "$var" See: Why does my shell script choke on whitespace or other special characters? When is double-quoting necessary?


0

Your command does work for me. Try running with export LC_ALL=C to remove any language issues. And add -w to your perl command to turn on warnings. Check that there is no whitespace after vertices in alpha.txt. You may want to hexdump your input: xxd alpha.txt to check for invisible bytes that may be preventing your regex from matching, such as the ...


0

In Bash you can run: for i in {1001..3000} ; do rm file_"$i".dat ; done


9

Use a function instead; the quoting is simpler: ios () { iostat -xk 2 $(findmnt -T ~ | awk 'END {print $2}') }


0

Apart from this (HISTFILESIZE), there is one reason why a line won't appear in history: A leading space. If you start a command with a space in the front like this: $ ls -l $ ls -l (extra space at the beginning) then the latter won't show up in history. Related, here is what my .bashrc looks like: .bashrc:HISTCONTROL=ignoreboth .bashrc:export HISTSIZE=...


2

A shell on its own has no way to interact with the user's desktop - it needs to be attached to a terminal device of some kind. For example: * * * * * DISPLAY=:0 gnome-terminal -- /home/user/sayhello.sh or * * * * * DISPLAY=:0 xterm -e /home/user/sayhello.sh You may need to arrange for the terminal to stay open after the command exits - either through its ...


0

Did you try sudo chmod +x sayhello.sh? I noticed you said -x, perhaps that is the issue. -x removes permissions to execute whilst +x adds it.


0

Setting all asterisks * * * * * tells crontab to run the command every minute of every day of every week of every month. You have to specify the times when you want to run the script: # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any')....


0

You should use option -e or -x to gnome-terminal. According to man gnome-terminal: -e, --command=STRING Execute the argument to this option inside the terminal. -x, --execute Execute the remainder of the command line inside the termi‐ nal.


0

Nested quotes are always trouble. You can do it like this: echo 'Hello '\'~\'' world'


5

alias ios='iostat -xk 2 $(findmnt -T ~ | awk 'END {print $2}')' you can not use quotes inside quotes. Alternate between quote and doublequote is the easiest method. So this works: $ alias ios="iostat -xk 2 $(findmnt -T ~ | awk 'END {print $2}')" $ From edit: Note that although it works in this case (because ~ isn't going to move to a different ...


0

Put the two commands you specified at the top of your question into a shell script. Put the script for example in /path/to/home/bin/recorder (of course the file needs to be executable and don't forget to insert #!/bin/sh at the beginning). Then edit the default profile in your gnome-terminal and set the command to run at startup to /path/to/home/bin/recorder,...


2

No, you cannot pass a password when logging in over a serial line. Over a serial line, you are logged by a process that is called [a]getty and it will display a prompt for a username and a password. Now, (because this PuTTY question appears off-topic to me) if you'd like to ask whether you could have a user 'logged in' at a serial port at all times without ...


0

I was using VS code within my WSL environment to edit the bash script, changing the setting from "CRLF" to "LF" on the bottom right corner fixed it for me.


2

You can use find . -type f -mtime +30 -exec rm -f {} \; or simpler find . -type f -mtime +30 -delete That will delete all files modified more than 30 days ago.


5

It turns out there was a little more nuance than I was aware of: HISTFILESIZE determines the maximum number of lines saved in .bash_history, while HISTSIZE determines the number of lines from ~/.bash_history loaded into a searchable cache. Upon increasing HISTSIZE to match HISTFILESIZE, I was able to find the command via Ctrl-r.


0

This Answer is for the ansible users. I had the same problem, I created a dummy file, encryped it, and used the gpg-agent to cache the password like suggested by mkudlacek, but with the ansible expect module. I used the following tasks: - name: create test.txt, created a dummy file file: path: /opt/anevis/repo/test.txt state: touch mode: u=rw,g=...


0

My solution: find . -type f ! -newermt "$(date -d 'now - 1 month' +'%D %T')" -exec rm -f {} \;


6

According to man find, you can use strings that the date command recognizes. -newerXY reference Succeeds if timestamp X of the file being considered is newer than timestamp Y of the file reference. The letters X and Y can be any of the following letters: a The access time of the file reference B The birth time ...


1

This file should be owned by you. Since it is owned by root instead for some reason, you cannot write to it so your shell history cannot be saved. Just fix the ownership and permissions: sudo chown paul:paul /home/paul/.bash_history chmod a+r /home/paul/.bash_history After this, the file should look like this: $ ls -l /home/paul/.bash_history -rw-r--r-- 1 ...


0

You should start the screen command before reading from the fifo. This example will list the current directory in screen and the nonexistent path error will be redirected to the fifo. #!/bin/bash [[ -p screen.fifo ]] \ || mkfifo -m 660 screen.fifo exec 3<>screen.fifo session=test screen -ls $session >&- || screen -dmS $session ...


0

It's very likely that a non-printing character is lurking around in one of the lines. Just pipe the output into cat -t to display any non-printing characters: diff file1 file2 | cat -t


1

Turns out, I've been going about it wrong. In order to run a script when the Gnome shell boots up, use the command gnome-session-properties and add a .sh script to it.


0

I wrote a script this afternoon to make it easier to change directories. Usage When you call cdd and there is more than one sub-directory you need to pick one: In this screen if you click OK button it is equivalent to: cd Seven\ Mary\ Three or: cd "Seven Mary Three" When you call cdd and there is only one sub-directory it automatically changes ...


0

It's annoying have to type out long sub-directory names with spaces. So I created a little function in ~/.bashrc that automatically changes down one sub-directory level if there is only one sub-directory. If there is more than one sub-directory then zenity is used to pick one to change to. cdd () { OFS="$IFS" # ...


0

Try this: Download this package: https://launchpad.net/~thierry-f/+archive/ubuntu/fork-michael-gruz/+files/cnijfilter2_5.90-1+2004+1ubuntu1_amd64.deb Assuming it was downloaded at ~/Downloads To install it run in a terminal: cd ~/downloads sudo dpkg -i cnijfilter2_5.90-1+2004+1ubuntu1_amd64.deb sudo apt -f install


13

You have a race condition - first find finds ./a and copies it to test/a, then it finds the newly copied ./test/a and tries to copy it again: $ find . -mtime -1 -name a -print -exec cp -v {} test/ ';' ./a './a' -> 'test/a' ./test/a cp: './test/a' and 'test/a' are the same file You could avoid that by telling find not to descend into the target directory ...


5

You can use bind to create a new keybinding, for example: bind '"\C-g":"ls\n"' Now press Control-g to invoke ls. However, ls will still be saved in history. You can add it to HISTIGNORE though.


0

The output of man mkfs.ext4 says the following: -q Quiet execution. Useful if mke2fs is run in a script. While this answers your immediate question, you should take a look at the rest of the man page. It explains why some of the commands you've tried won't work as you expect.


0

To start in interactive bash inside a gnome-terminal with some commands already executed I put those commands in a setup file and dynamically append the contents to my .bashrc file: # my_startup_script.sh export FOO=bar echo "hello world" gnome-terminal --tab -- bash -c "bash --rcfile <(cat ${HOME}/.bashrc my_startup_script.sh; )" =&...


0

The difference is more clear when you know when these two files are executed which is dependent on the type of login being performed. In Linux you can have two types of login shells, Interactive Shells and Non-Interactive Shells. An Interactive shell is used where a user can interact with the shell, i.e. your typical bash prompt. Whereas a non-Interactive ...


0

There's two kinds of SIGHUP that can be involved here. First, because in this kind of situation, the shell will be a so called Controlling Process (a session leader shell in ownership of a controlling terminal--a pseudoterminal created by the ssh login), a terminal driver will be obligated to send SIGHUP to all members of the foreground process group of the ...


2

The ps command reports the CPU usage of a process in seconds. If you want to get this information in milliseconds, you can look at the end of this answer. ps truncates the total CPU time used by the process to the nearest low second, so you can safely assume that the process you looked up (bash in your case) had used less than one CPU second so far. This is ...


0

The Maim screenshot tool aims to be a better choice than scrot. Systemd.timer works as a time-based activation. By default, your timer activates a service with the same name. Scheduling your task, you can either use a real-time timer defined by calendar expressions or monotonic timers that start the moment the timer itself activates (or you can combine them ...


0

Bash aliases are not "real" executables and cannot be called from outside of bash. You either need to access environment variable(s) from within your C++/Python/whatever program to rebuild the full path to headas-init.sh, create an actual bash script that calls headas-init.sh and then call that script in your own program, or call /bin/bash and ...


3

OK, a few different things: To be pedantic, you haven't given the script executable permission, you've given your user permission to execute the script. This sounds like the same thing but it is critically different. The file is inert so it's the user that must take the action that would potentially matter here. As an easy way to kind of look at the ...


0

Shortening WinEunuuchs2Unix answer a bit: distro=$(lsb_release -i |cut -f2) echo "${distro,,}" os_version=$(lsb_release -r |cut -f2) echo "${os_version}" On Ubuntu 20.04, the following is shown: ubuntu 20.04


4

Since the "oldnames" appear to be lexically ordered, and assuming that the "newnames" are arranged one per line in a text file (i.e. can't contain newlines) then you should be able to use a simple for loop / shell glob like for oldname in bcf*/; do IFS= read -r newname || break echo mv --no-clobber -- "$oldname" "$...


0

In my testing, when a non-root user runs locate, contents of directories the non-root user does not have read access to are not displayed. In your case, what are the permissions on /home/example? If user limited does not have read access on /home/example, locate will not show matching files in that directory when run by limited. Assuming there aren't any ...


0

This did it for me: sudo apt-get install linux-generic sudo apt-get install v4l2loopback-dkms sudo modprobe v4l2loopback Got the solution from here modprobe v4l2loopback fails on Ubuntu During the install of v4l2loopback-dkms I had to do the 'Enroll MOK' process (it guided me automatically). After this I uninstalled and reinstalled Droidcam and the webcam ...


0

You can shorten it a bit but the target needs to exist: $ mkdir -p yicky/other-stuff; mv -t $_ sicky/infinity/{[mf]oo,tmp}


2

mmv (from the package of the same name) is useful for cases like this: $ mmv -n '*-bcF_01_bcR_*.*' 'bcF_01_bcR_#2/' round3-bcF_01_bcR_01.R1.fastq -> bcF_01_bcR_01/round3-bcF_01_bcR_01.R1.fastq round3-bcF_01_bcR_01.R2.fastq -> bcF_01_bcR_01/round3-bcF_01_bcR_01.R2.fastq round3-bcF_01_bcR_02.R1.fastq -> bcF_01_bcR_02/round3-bcF_01_bcR_02.R1.fastq ...


2

Using rename to move files: $ rename -n 's/.*(bcF_[0-9]+_bcR_[0-9]+).*/$1\/$&/' *.fastq Remove -n when you feel ready to move your files.


2

In this particular case, probably the most simple way is to use the builtin for loop in a way as this: for i in {01..08}; do echo mv *-bcF_01_bcR_${i}* bcF_01_bcR_${i}/; done remove the echo command in order to do the actual file-system changes.


0

I ran into a similar issue. And the reason was special characters in the device URI. Try replacing the URI special characters with its respective URL encoding. Ex:- # as %23


Top 50 recent answers are included