linux:bash:remove-n-last-char

BASH: Remove last -n Char String / Menghapus -n karakter diakhir dan diawal

Berikut ini adalah cara menghapus last -n karakter dari string

Menghapus n karakter di akhir

#!/bin/bash

v="some string.rtf"

v2=${v::-4}

echo "$v --> $v2"

Menghapus n karakter di awal

#!/bin/bash

v="some string.rtf"

v2=${v:4}

echo "$v --> $v2"

Sumber : https://stackoverflow.com/questions/27658675/how-to-remove-last-n-characters-from-a-string-in-bash

Layanan

Harga Domain .COM | Harga Domain .ID | Shared Hosting | Email Hosting | MySQL Hosting |
linux/bash/remove-n-last-char.txt · Last modified: 2024/01/02 22:12 by kbadmin

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki