Skip to content

Tag: bash

output mountpoint on (usb)device detection

I want to create a bash script that will output the mount point from an inserted USB device. I have two commands (between “do” “and” done”) that work separately but not together in a bash script. The script looks for a UUID file use the $UUID filename in the lsblk command to extr…

How to resize the block of a column

I have a single column of a file having many blocks and the blocks are separated by the > symbol. I want to resize all blocks to the same highest length by appending zero below them. My file is given below: file.txt and my expected output is given below I am trying to write a script, but it fails: Answer

Can we store “cd ..” path in a variable in bash file?

I am new to the bash my use case is to store the one previous directory in to a variable. Example: How can we add /local/ to any variable like $PREV? Answer You can use parameter expansion on $PWD which contains the current path: Or, use an external tool like readlink with command substitution: