Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

split string in shell script

IN="bla@some.com;john@home.com"
arrIN=(${IN//;/ })
echo ${arrIN[1]}                  # Output: john@home.com
Comment

split string in shell

#!/usr/bin/env bash

# There are different method of splitting a string.
# Two of those methods are shown below

# a sample string delimeted by ";"
IN="FirstName=John; LastName=Doe; Email=jd@someone.com"

# First method:
# splits the string on ';' and puts them into an array
person=$(echo $IN | tr ";" "
")

# you can loop through the array
for info in $person
do
    echo "> [$info]"
done



# Second method:
echo "$IN" | cut -d ";" -f 1  # returns the first part
echo "$IN" | cut -d ";" -f 2  # returns the second part

#and so on.

Comment

split string using linux cmd

$ s='one_two_three_four_five'

$ A="$(cut -d'_' -f2 <<<"$s")"
$ echo "$A"
two

$ B="$(cut -d'_' -f4 <<<"$s")"
$ echo "$B"
four
Comment

split command in linux

Split command in Linux is used to split large files into smaller files. 
It splits the files into 1000 lines per file(by default) and even allows users to change
the number of lines as per requirement.

The names of the files are PREFIXaa, PREFIXab, PREFIXac, and so on. 
By default the PREFIX of files name is x and the default size of each 
split file is 1000 lines per file and both the parameters can be changed with ease.
It is generally used with log and archive files as they are very large 
and have a lot of lines, So in order to break them into small files for analysis
split command is used.

Syntax:

split [options] name_of_file prefix_for_new_files
Comment

PREVIOUS NEXT
Code Example
Shell :: npm install webpack 
Shell :: docker elasticsearch latest version 
Shell :: INSTALL VMwareTools on terminal ap=get 
Shell :: graphql comment 
Shell :: install aws cli v2 on mac 
Shell :: postgres users can login with any or no password 
Shell :: git pull from previous commit 
Shell :: docker compose up only one service 
Shell :: uptime linux 
Shell :: wsl file 
Shell :: Octave Install Packages Commands 
Shell :: uninstall get help windows 10 
Shell :: open port on firewall linux 
Shell :: how to install a library in anaconda 
Shell :: powershell get all computers in ou 
Shell :: how to delete a commit from a branch 
Shell :: aab to apk 
Shell :: create patch in git 
Shell :: powershell do while loop 
Shell :: undo merge 
Shell :: install laravel dompdf 
Shell :: bash length of array 
Shell :: redis remove key 
Shell :: download nodejs debian linux 
Shell :: change crontab editor 
Shell :: how to install docker in ubuntu 
Shell :: add npm to $PATH ubuntu 
Shell :: look like hacker linux 
Shell :: clone a particular branch 
Shell :: list inactive services ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =