New answers tagged

0

You can use shell parameter expansion to add zero-padding to numbers. For example, to print number in a 5-digits format: zeroos=00000 number=123 temp_num="$zeroos$number" echo ${temp_num:(-5)} # 00123 Another way: echo ${zeroos:${#number}:${#zeroos}}${number} # 00123 Note that printf could be mush slower on large scale (see example).


3

Add this line to ~/.bashrc alias cd..="cd .."


4

alias cd..="cd .." Use an alias.


2

The shell isn't interpreting anything - it's simply passing -O (after quote removal) to the grep executable, which parses it as part of its argument vector argv[] You can either signal the end of options using -- echo "#fastq-dump SRR3105676 --gzip -O my &" | egrep -- "-O" or (for the case of grep specifically) use the -e option (or ...


3

The error means that you compiled your Java program with a version of the compiler that is more recent than the version of the Java virtual machine you're trying to execute the compiled code. In your case 58 means Java 14 and 55 means Java 11. Thus, you compiled your program with Java 14 and you're trying to execute the compiled code with Java 11. Probably ...


1

You want to start by reading the file labeled "README". It will tell you everything that you need to know about installing the program (or at least it should). You can ignore the hcxtools.git directory. I highly recommend getting to know git a bit more by running through some basic tutorials, but for now you can ignore that directory completely. I ...


2

Up until Ubuntu 18.04 LTS, both python2 and python3 were preinstalled on Ubuntu. Since Ubuntu 18.04 LTS, things have changed. Python2 is not preinstalled. Only python3 (v3.8.2 in 20.04) is preinstalled. At this moment if you run python3 --version, you will see version 3.8.2 is installed. However if you have also installed python 2 (on your own, it is not ...


2

& is one of very few characters that is special on the replacement side of a sed s/pattern/replacement/ command - in particular, it is replaced by the whole matched portion of the pattern space. In this case, the whole matched portion is a zero length assertion $, so & appears to insert nothing in the replacement. To add a literal ampersand, you ...


1

The screen package is in the Ubuntu repositories for all supported releases of Ubuntu. Make sure you are running a currently-supported release of Ubuntu. Make sure to run sudo apt update to populate your database of available packages. Read your output to ensure the command completed successfully. $ rmadison screen screen | 4.0.3-14ubuntu8 | ...


0

There is an issue with terminus (and bitmap fonts in general) in recent Ubuntu. The issue is of both technical and personal nature. Technical part is that old formats of bitmap fonts are difficult to maintain, so pango developers decided to drop them. Political part is that many people believe that for hi-dpi monitors pixel fonts are no longer needed, so ...


0

Input JSON file (test.json): {"url":"http://example.com/vary/file/","originalUrl":"http://example.com/vary/file/"} Code to modify as per requirement and re-write to same file: import json with open("test.json") as fh: data = json.load(fh) for k,v in data.items(): data[k] = v.replace("http://&...


1

I believe I ran into the same issue as the poster and this was the first post I came to, I have since realized what I was doing wrong so will post here in case it helps others (at the time of writing no other answers or comments here mentioned the key piece of info I was after). From the official docs for ln: When creating a relative symlink in a different ...


0

when you install the Ubuntu using WSL then default location of your saved files are: all your files should be present "C:\users\username\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home"


3

Not sure what is the purpose of the script but this solution should work: for file in *.aac; do ffmpeg -i "$file" -an -vcodec copy "${file%aac}jpg" ffmpeg -loop 1 -i "${file%aac}jpg" -i "$file" -c:v libx264 -preset veryslow -tune stillimage -crf 18 -pix_fmt yuv420p -c:a aac -shortest -b:a 192k -shortest "$...


1

I resolved this issue on my system by going to Settings -> Displays -> Scale = 100% -> Apply It appears that having a scale other than 100% will cause the installer to not work properly.


0

Resolve symlink before processing the file. foo.sh #!/bin/bash # Mark variable for export. declare -xi LVL # Resolve absolute pathname. filename=$(realpath "$0") # Strip .sh suffix from file and check for exec bit. ((LVL++ < 1)) && [[ -x "${filename%.sh}" ]] || exit 1 export LD_LIBRARY_PATH="${filename%/*}" # Run ...


5

As others have mentioned ${_[0]} is extra typing for ${_} which in turn can be abbreviated into $_ as it is most commonly used. As mentioned previously it is a variable that contains the last parameter of the last command used. A practical application is like this: $ ll /etc/lsb-release -rw-r--r-- 1 root root 105 Feb 20 2019 /etc/lsb-release $ cat $_ ...


0

For charts + the 30,000 feet view of representative actual speeds I was looking for: A broad, multi-ISP, representative view of real-life speeds Upload-speeds + round-trip latencies. Not just download speeds Eliminate ISP bias and possible tricks they might play to make specific speed-tests appear faster than most other speeds are High-level graphical ...


18

The _ parameter has several meanings depending on context, but it is never an array. Likewise, in your example, x is not an array. The reason you're able to treat it as if it is an array is that Bash allows non-array variables to be treated as if they were one-element arrays. Bash likewise allows array variables to be treated as if they were non-arrays, ...


12

$_ is a special parameter. It is used in a number of ways but, in your case, it refers to the last argument of the previous command: $ echo hi Hi Hello hi Hi Hello $ echo "$_" Hello Since $_ is a variable, not an array, the syntax ${_[0]} is just useless clutter that accesses $_: $ echo "$_" Hello $ echo "${_[0]}" Hello ...


0

Since /etc/issue is written to every virtual console, try appending the output of your setterm command: cp /etc/issue /etc/issue.original setterm --blank 1 --powerdown 2 >>/etc/issue I've been using this approach with Ubuntu for a couple months now.


0

Check you i3 config file: # start dmenu (a program launcher) bindsym Mod1+d exec dmenu_run # There also is the (new) i3-dmenu-desktop which only displays applications # shipping a .desktop file. It is a wrapper around dmenu, so you need that # bindsym Mod1+d exec --no-startup-id i3-dmenu-desktop By default it's using dmenu_run which will list only programs ...


1

Simple, remove the new line you added from the file ~/.bashrc. Here's a quick guide: Open a terminal. Type in gedit ~/.bashrc. In the editor, look for the line that has . torsocks on on it. Remove that line and save using CTRL + S or pressing the Save button. Open a terminal and confirm it no longer shows up (you may also need to reboot the system). Hope ...


2

The reason you were getting the error you were getting is because in the terminal < and > have special meaning. < means to send command on the right into application or commands to the left - and the same is said about > but in reverse. If you are typing in diskutil unmountDisk < drive address > into the terminal, this could be your problem....


0

So the process follows these steps: Find your storage device in /dev/: sudo fdisk -l Which will probably print out a lot of info. You can find which Device by looking at the Size column that matches your usb (Be more discerning , perhaps looking at storage type, if you have more than one device with the same storage size). Also, if the Device is sdb then you ...


-2

The first line should be if [[ $1 == "-tl" ]] ...otherwise you are setting the value of $1. And the term line should be gnome-terminal -x "$0" -tl ...$0 is the path to the running script


2

The precise question you are asking is a little unclear to me, but I think what you are trying to do is very much possible. It sounds like you want to connect over the Internet, not just your local network. You'll want to first try getting it up and running locally, then work on connecting from outside. At a very high level, here are the basic steps: First, ...


0

This makes the copying of IP addies simpler: alias ifconfig="ip -c a | sed -e 's/\// \//g'" (otherwise that subnet slash prevents doubleclick->select of only the IP)


2

You are running sync with sudo, but not the shell's redirection of the echo. Instead do: sudo sh -c 'sync; echo 1 > /proc/sys/vm/drop_caches' or sudo sync; echo 1 | sudo tee /proc/sys/vm/drop_caches >/dev/null


1

I just installed Debian on a platform with the same GPU and had a similar "what the heck" moment. I managed to make it slightly less horrible by telling the kernel to use an 8-bit screen mode by adding this to the GRUB_CMDLINE_LINUX: video=1024x768-8 Lower resolutions were even faster, but 1024x768 was the sweet spot for me. This took it from ...


1

The example you showed will work. Is there a problem when testing it? One issue with using ; to chain commands is that all of them always get executed. This might be a problem for your script, as steeldriver mentioned. Instead of using ; you may prefer to use && in this case, to have the notification display only when the script ran successfully. ...


1

A very simple example that will help you is : # OPTION 1 CURDIR=$( pwd ) # OPTION 2 CURDIR=$PWD D1="XXXXXX" D2="YYYYYY" mkdir $D1 cd $D1 mkdir "foo_bar" cd "foo_bar" cd $CURDIR mkdir $D2 3 things to know about this : 1.a) pwd is a command to display the current name of current folder 1.b) $(....) is a way to ...


2

$ awk ' BEGIN {OFS=FS=","} NR==1 {print "firstname","lastname","chargetotal","customerID"} FNR>1 {fname[$1]=$2; lname[$1]=$3; chargetotal[$1]+=$4} END {for(i in chargetotal) print fname[i],lname[i],chargetotal[i],i} ' file.csv firstname,lastname,chargetotal,customerID jeny,vel,38.39,4a7f057 Romo,...


1

Thanks to @Archisman Panigrahi I realized that my system and the Swift binaries were from different architecture types. I found in GitHub some Swift for ARM projects, but they lack some stuff, so I'm waiting for a fully-supported official version of Swift for ARM.


0

You can use this command to quit telnet: echo quit | telnet servername portnumber


1

It's likely because you are passing it a non newline-terminated string: $ printf 'foo,bar,baz\n' | column -t -s, foo bar baz but $ printf 'foo,bar,baz' | column -t -s, column: line too long Perhaps consider replacing sed -z "s/\n/,/" in your pipeline with paste -sd,


1

It seems like you are trying to execute a program that might not be a valid Linux binary; a quick search for this error online will return many sites explaining how to solve it, like these: bash: ./program: cannot execute binary file: Exec format error https://superuser.com/questions/800019/unable-to-execute-binary-file-exec-format-error https://appuals.com/...


1

You forgot to escape the $ signs in the $(printf...) parts by doubling them to $$, so make is doing that part itself and does not find an expansion. If you prefer you can use $(shell printf '\033[0;1;31m') to have make run the command.


4

Your method is great, but looks too long. While transforming Linux Mint to Ubuntu I have used the command like: sudo find /bin -type f -exec dpkg -S {} \; 2> ~/Desktop/not-in-apt.out and as the result for your case we will get wrong copied files list in ~/Desktop/not-in-apt.out. You can then review the file and remove files listed in it. Or use some ...


8

Piece together solutions available in Stack Exchange. If you do enough research you will find a solution by combining these five answers: How do I compare file names in two directories in shell script? How can I remove the first line of a text file using bash/sed script? Command to prepend string to each line? giving grep output to rm How do I make rm not ...


0

Yes, it is true that the date command is less effective compared to taking a look at the desktop gui, but using your desktop might also be less convenient compared to your phone. However, this command is very useful when you actually have no gui support or any clock prompt, and even more useful when logging scripts and automations. Here is an example of a ...


0

While ping -a IP_ADDRESS makes an audible beep (like echo -e "\a") every time it success, I have not found any option in the standard ping command to beep when failure. Based on @Requist answer, one line that using crontab sets up the desired behavior every 5 minutes may be: (crontab -l 2>/dev/null; echo "*/5 * * * * /bin/ping -w 10 -c 4 8....


1

Yes, there is something different about the virtual consoles depending on which version of Ubuntu you have updated from. On older versions of Ubuntu, lightdm was present on TTY7. However on newer versions, GDM is present on TTY1 and TTY2. So on 20.04, you should be able to access a virtual console on TTY3~TTY8. Please see this similar question if you would ...


2

Ubuntu now has an option under wifi network settings to limit connection use to local resources. Settings > Wifi > Gear Icon > IPv4/IPv6 Check the tickbox next to use this connection only for resources on its network


0

Your ./makeDist command is failing due to a --releasedate date formatting problem. You have: ./makeDist --nosyntaxCheck --releasedate "date -u "+%d %b %Y"" --version $VER So use this: ./makeDist --nosyntaxCheck --releasedate $(date -u '+%d %b %Y') --version $VER Or this: ./makeDist --nosyntaxCheck --releasedate '30 Jun 2020' --version $...


4

I don't know anything about the structure of FASTA, but if the substring Otu cannot appear anywhere else in the header, then sed 's/^>.*Otu/>Otu/' file.fasta should do it


6

A function can't do this for arbitrary non-simple commands in bash, since a function itself is a simple command - by the time the function definition comes into play, it's way too late. Expansions of aliases can contain pipelines, so you can add piplines in an alias, but of course only at the beginning of the command: $ alias e='echo foo |' $ e grep bar # ...


13

Process substitution may offer the closest syntax to what you want. This works, and may be to your liking: vim <(cmd1 | cmd2 | ...) That lets you keep the text of your whole command together, and to put it after (rather than before) the command that sends it to vim, which seem to be your main goals. The absence of a - argument is intentional. You don't ...


-1

There is a bug report on this problem: Unable to use 'locate' to locate files mlocate.db permission denied I didn't follow any of the suggestions there because I know how I had broken my system by using chown to $USER on / instead of /tmp/$USER/ recursively. It took a day to rebuild my system to boot. locate command is one of the left over things to fix. ...


Top 50 recent answers are included