Saturday, 13 Dec 2025
Subscribe
logo
  • Global
  • AI
  • Cloud Computing
  • Edge Computing
  • Security
  • Investment
  • Sustainability
  • More
    • Colocation
    • Quantum Computing
    • Regulation & Policy
    • Infrastructure
    • Power & Cooling
    • Design
    • Innovations
    • Blog
Font ResizerAa
Data Center NewsData Center News
Search
  • Global
  • AI
  • Cloud Computing
  • Edge Computing
  • Security
  • Investment
  • Sustainability
  • More
    • Colocation
    • Quantum Computing
    • Regulation & Policy
    • Infrastructure
    • Power & Cooling
    • Design
    • Innovations
    • Blog
Have an existing account? Sign In
Follow US
© 2022 Foxiz News Network. Ruby Design Company. All Rights Reserved.
Data Center News > Blog > Global Market > How to work with substrings on Linux
Global Market

How to work with substrings on Linux

Last updated: August 20, 2024 5:44 pm
Published August 20, 2024
Share
SHARE

$ echo "Concentrate on Peace on Earth" | reduce -d' ' -f3,5
Peace Earth
$ echo "one two three 4 5 6" | reduce -d' ' -f1-3,6
one two three 6

To make use of an alternate delimiter (on this case, a colon), use a command like this:

$ reduce -d':' -f1-3,5,6 /and so forth/passwd | tail -n 5
justme:x:1004:JustMe:/dwelling/justme
lola:x:1006::/dwelling/lola
dumdum:x:1007::/dwelling/dumdum

With awk, you need to use a couple of delimiter. Within the following instance, two delimiters are specified, so the awk command accepts both a colon or a clean to separate fields. The primary two strains show the file, and the final two strains present the command and end result.

$ cat file
Monday:1 Tuesday:2 Wednesday:3 Thursday:4 Friday:5
$ awk -F'[: ]' 'OFS=" ";print $1,$3,$4' file
Monday Tuesday 2

Choosing substrings

To pick out an arbitrary sequence or characters from a string, you need to use an awk command just like the one under during which the $0 represents the whole phrase, 10 represents the primary character place to be grabbed and 5 is the size of the string to be displayed.

$ echo "Concentrate on Peace" | awk 'print substr($0,10,5)'
Peace

To do the identical type of factor with the reduce command, you’d use a command like this during which the 13th by 22nd characters are extracted from the phrase and displayed.

$ echo "Linux is a formidable OS" | reduce -c 13-22
spectacular

On this subsequent command, the reduce command shows the 7th-12th characters from the strains in a file. The head command merely limits the show to the primary 4 strains of output.

$ reduce -c 7-12 sayings | head -4
with 3
and ov
nd be
and be

Utilizing grep

You should utilize the grep command to pick a number of phrases from a file. On this instance, solely the chosen phrases are displayed, not the whole strains. It’s because the -o (show solely the matched objects) choice is getting used.

See also  Data center growth puts unprecedented pressure on power grids

Source link

Share This Article
Twitter Email Copy Link Print
Previous Article Cloud Computing News 9 SOC 2 compliance software to look out for in 2024
Next Article AI governance must improve at board level, says Norway's sovereign fund Use of AI for business governance must improve at the board level
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Your Trusted Source for Accurate and Timely Updates!

Our commitment to accuracy, impartiality, and delivering breaking news as it happens has earned us the trust of a vast audience. Stay ahead with real-time updates on the latest events, trends.
FacebookLike
TwitterFollow
InstagramFollow
YoutubeSubscribe
LinkedInFollow
MediumFollow
- Advertisement -
Ad image

Popular Posts

Using AI to turn everyday objects into proactive assistants

A stapler on prime of a moveable platform that may anticipate when an individual might…

October 15, 2025

Thailand Data Center Colocation Market Supply & Demand Analysis Report 2024-2029 Featuring Existing and New Players Such as Telehouse, Evolution, AIS-Singtel & Gulf Energy, Edge, CtrlS Among Others

DUBLIN–(BUSINESS WIRE)–The “Thailand Data Center Colocation Market – Supply & Demand Analysis 2024-2029” report has…

February 7, 2024

Anthropic’s Computer Use mode shows strengths and limitations in new study

Be part of our each day and weekly newsletters for the newest updates and unique…

November 30, 2024

Lenovo launches ultra-compact AI inferencing server for the edge

Lenovo unveiled the ThinkEdge SE100, the primary compact, entry-level AI inferencing server designed for edge…

March 11, 2025

Pinterest debuts Canvas AI at VB Transform, reshaping visual discovery

Be part of our day by day and weekly newsletters for the newest updates and…

July 15, 2024

You Might Also Like

Why data centre megadeals must prove their value
Global Market

Why data centre megadeals must prove their value

By saad
photo illustration of clouds in the shape of dollar signs above a city
Global Market

Cloud providers continue to push EU court to undo Broadcom-VMware merger

By saad
Kao SEED Fund awards £30,000 to Harlow community projects
Global Market

Kao SEED Fund awards £30,000 to Harlow community projects

By saad
Close Up Portrait of Woman Working on Computer, Lines of Code Language Reflecting on her Glasses from Big Display Screens. Female Programmer Developing New Software, Coding, Managing Cybersecurity
Global Market

FinOps Foundation sharpens FOCUS to reduce cloud cost chaos

By saad
Data Center News
Facebook Twitter Youtube Instagram Linkedin

About US

Data Center News: Stay informed on the pulse of data centers. Latest updates, tech trends, and industry insights—all in one place. Elevate your data infrastructure knowledge.

Top Categories
  • Global Market
  • Infrastructure
  • Innovations
  • Investments
Usefull Links
  • Home
  • Contact
  • Privacy Policy
  • Terms & Conditions

© 2024 – datacenternews.tech – All rights reserved

Welcome Back!

Sign in to your account

Lost your password?
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.
You can revoke your consent any time using the Revoke consent button.