Connect with us

# How to use the grep command for better data retrieval

#### More Videos

Automating the performance of tasks via scripting is something we all strive to do as IT pros. But taking it a step further by using grep adds a layer of granularity and universality to your scripts.

Interacting with data is the core function of any IT professional. Each role is unique and brings with it specific challenges, but at the heart of each role lies the same basic premise: As IT, we interpret and respond to the data we receive and if it isn’t accurate, we take measures to correct the data flow. When we automate tasks based on scripts, it is typically done in response to known parameters and provides a predetermined set of commands to execute, thereby automating repetitive tasks.

This is great and, I whole-heartedly recommend that IT pros automate where possible to maximize performance and limit downtime for all stakeholders. But what if you could execute commands or write scripts that would provide information and make changes (execute commands) based on the responses? You could automate tasks with a bit of logic baked in to allow for the script to account for a variety of possibilities  limited only by your imagination or script writing capabilities.

Scripts like these may be found in many popular forums or GitHub, and as long as they are tested and verified to work for your environment, you should definitely implement them where feasible. But if you’re more of the do-it-yourself type, wish to learn this hands-on, or cannot find a suitable, pre-authored solution, may I introduce the grep command to you?

Grep is natively found in Linux and macOS systems. It is also available as an installable package for Windows.

## What is grep?

According to the grep man page in macOS, “The grep utility searches any given input files, selecting lines that match one or more patterns.” This means that grep essentially searches for data that matches a specific set of words or patterns that you tell it to look for. The input for grep to search may come from files fed to the utility or is more commonly used in conjunction with the output of commands that are piped into grep after execution to identify certain bits of data.

## Why should I use grep?

Besides cutting down, perhaps drastically, on manually searching files or command outputs for specific data or responses, as mentioned before, grep can be included in a chain of commands with the output of a previous command piped into the input for grep to sift through. This allows for the output from grep to be piped into a subsequent command to execute another command against, and so on. When combined with other commands within a script, grep may be used to read information from one file to determine if the command should proceed in one direction or another, cutting down on the number of scripts to maintain (and update).

SEE: Navigating data privacy (free PDF) (TechRepublic)

## What are some examples of grep in action?

Below I’ll provide some real-world examples of grep in use within scripts to establish an understanding of how grep works and highlight how well it plays with other commands. It’s up to you to see how it can be integrated to add universal functionality to your scripts.

### 1. Verify hash value for an update before installation

In the example below, we have a file called “macOS_Update01.pkg” that we wish to install but want to verify the hash value to make sure the file’s integrity is intact. We know the hash value is “9aac9b799f3bb26da66f886024e1af58a1b4d3a7” and as is common practice, we have a file named “hash.sha” with the SHA1 value stored in it. By running the grep command below with the known hash value stored in the checksum file, the string will perform a check on the values, comparing them. If it matches, the Terminal will output the filename on-screen to confirm integrity.

grep 9aac9b799f3bb26da66f886024e1af58a1b4d3a7 hash.sha

### 2. Determine the software version of macOS and export non-matched devices

In this example, we are running a command to determine when the current running version of macOS is installed on a group of devices. The ones that do not match 11.1 will be exported to a list titled NeedsUpdating.csv for review. The output of the first command will be piped into grep to whittle down the info that matches the requirement.

sw_vers -productVersion | grep -v 11.1 > "NeedsUpdating.csv"

## Also see

0
Click to comment

# GeoSim: Photorealistic Image Simulation with Geometry-Aware Composition

Humans can synthesize unperceived events in their heads, for instance, to imagine how an empty street would look during rush hour. The similar capability of computers may be useful in film making or augmented reality.

A recent paper proposes GeoSim, a realistic image manipulation framework that inserts dynamic objects into existing videos.

Image credit: Unsplash/Kimi Lee

This method uses the data captured by self-driving cars to build a 3D assets bank. Then 3D scene layout from LiDAR readings and 3D maps is used to add vehicles in plausible locations. The Intelligent Driver Model is used so that the new objects have realistic interactions with existing ones and respect the flow of traffic. Neural networks are employed to seamlessly insert an object by filling holes, adjusting color inconsistencies, and removing sharp boundaries. It is the first approach to fully consider physical realism and outperforms prior research by qualitative and quantitative measures.

Scalable sensor simulation is an important yet challenging open problem for safety-critical domains such as self-driving. Current work in image simulation either fail to be photorealistic or do not model the 3D environment and the dynamic objects within, losing high-level control and physical realism. In this paper, we present GeoSim, a geometry-aware image composition process that synthesizes novel urban driving scenes by augmenting existing images with dynamic objects extracted from other scenes and rendered at novel poses. Towards this goal, we first build a diverse bank of 3D objects with both realistic geometry and appearance from sensor data. During simulation, we perform a novel geometry-aware simulation-by-composition procedure which 1) proposes plausible and realistic object placements into a given scene, 2) renders novel views of dynamic objects from the asset bank, and 3) composes and blends the rendered image segments. The resulting synthetic images are photorealistic, traffic-aware, and geometrically consistent, allowing image simulation to scale to complex use cases. We demonstrate two such important applications: long-range realistic video simulation across multiple camera sensors, and synthetic data generation for data augmentation on downstream segmentation tasks.

0

# Acer Announces Chromebook 511, Chrombeook Spin 512, TravelMate Spin B3, Two More Laptops Aimed at Students

Acer Chromebook 511, Acer Chromebook 311, Acer Chromebook Spin 512, Acer Chromebook Spin 511, and Acer TravelMate Spin B3 have been announced by the company. Designed with students in mind, the laptops are tested to meet the MIL-STD 810H durability standard, as per Acer. While the prices and availability of the laptops in the US and Europe have been revealed, it is not yet known when they will be available in in India.

Acer Chromebook 511 (C741L) will be available in the US in April starting at $399.99 (roughly Rs. 29,200) and in Europe in March starting at EUR 399 (roughly Rs. 35,400.) The Chromebook 511 by Acer is an 11.6-inch laptop powered by a Qualcomm Snapdragon 7c SoC. As per the company, it can last up to 20 hours on a single charge. It has 4G LTE connectivity. Acer Chromebook 511 has mechanically anchored keys and a drainage system built into its keyboard to protect the device’s internals from accidental spills. ## Acer Chromebook 311 price, specifications Acer Chromebook 311 (C722) is priced at$299.99 (roughly Rs. 21,900) in the US and will be available there starting this month. It will be available in Europe for EUR 269 (roughly Rs. 23,900) in March. It is aimed at “surviving the mishaps of a typical school day and is also suitable for more vulnerable young learners.”

This device is powered by a MediaTek MT8183 processor that the company says is designed around a number of industrial durability and safety standards. The keys have been mechanically anchored with two wings that extend out under the chassis. It has about 20 hours of battery life and has an option touch screen.

As per Acer, the Chromebook 311 is compliant with the MIL-STD 810H standard and can survive falls of up to 48.03-inch and withstand up to 60kgs. Acer also claims that the device can withstand up to 330ml of water.

[Acer Chromebook Spin 512] (R853TA) will be available in the US in April starting at $429.99 (roughly Rs. 31,455) and in Europe in March 2021, starting at EUR 399 (roughly Rs. 35,400). It comes with 8GB RAM and 64GB storage. It is powered by an Intel processer and has integrated Wi-Fi 6 and Antimicrobial Corning Gorilla Glass displays. It has a 12-inch HD+ IPS display and 3:2 aspect ratio screen for more vertical viewing. As per the company, Acer Chromebook Spin 512 has a battery life of 10 hours. It has an 8-megapixel MIPI world-facing camera and an 88-degree field-of view HDR webcam along with a privacy shutter. Acer Chromebook Spin 512 also includes antimicrobial coating. ## Acer Chromebook Spin 511 price, specifications Acer Chromebook Spin 511 (R753T) will be available in the US in April starting at$399.99 (roughly Rs. 29,300) and in Europe in March 2021, starting at EUR 369 (roughly Rs. 32,700). It is available in an 8GB + 64GB storage variant.

It has an 11.6-inch display in a compact chassis and is powered by an Intel processer. Acer Chromebook Spin 511 has a battery life of up to 10 hours, an 8-megapixel MIPI world-facing camera and an 88-degree wife field-of view HDR webcam. It has Wi-Fi 6 connectivity.

Acer Chromebook Spin 511 has a shock absorbent bumper and reinforced design. Two reinforced USB 3.2 Type-A ports and Bluetooth 5.1 are also included.

## Acer TravelMate Spin B3 price, specifications

Acer TravelMate Spin B3 laptop will be available in the US in April starting at \$329.99 (roughly Rs. 24,100), in Europe in Q2 2021 starting at EUR 409 (roughly Rs. 36,300), and in China in February, starting at CNY 2,499 (roughly Rs. 28,200).

It is powered by an Intel Pentium Silver processor. Acer TravelMate Spin B3 includes a durable keyboard that can flip around to turn the laptop into a tablet and is specially designed for classrooms, as per Acer. It can also be placed into tent mode, where the keyboard props up and balances the display.

It has up to 12 hours of battery life and a moisture-resistant touchpad. The display is covered with a layer of Antimicrobial Corning Gorilla Glass. It has an optional Wacom AES pen and a 5-megapixel HDR front-facing camera. Acer TravelMate Spin B3 laptop has Wi-Fi 6 and 4G LTE connectivity. The front cover of the device also includes a battery-level indicator.

Does WhatsApp’s new privacy policy spell the end for your privacy? We discussed this on Orbital, our weekly technology podcast, which you can subscribe to via Apple Podcasts, Google Podcasts, or RSS, download the episode, or just hit the play button below.

0

# Developers: How observability complements the future of monitoring

Commentary: Those who say observability killed monitoring aren’t paying attention. Here’s why.

You can be forgiven if you thought monitoring was passé. Nagios, for example, is probably the best known of the open source monitoring tools, but interest in it has steadily declined for over a decade. Meanwhile, observability tools like OpenTelemetry are hot, though “observability” is arguably a cool new term for much the same metrics, logs, and traces that we’ve been analyzing long before the term was coined.

Indeed, as Lightstep CEO Ben Sigelman has argued, observability isn’t going to replace monitoring “because it shouldn’t.” Observability is all about augmenting monitoring, not replacing it. Here’s why.

I suggested above that observability is really just a fancy way of saying “logs, traces, and metrics,” but that’s overly simplistic. Ultimately, according to Sigelman, observability is about telemetry and storage. Telemetry increasingly is synonymous with OpenTelemetry, the CNCF-hosted open source project. And storage? It’s more than a time series database or a database for storing logs, traces, and transactions. You need both.

The third thing Sigelman insists upon brings us back to monitoring: The health of the system (i.e., monitoring) and understanding change within those systems (i.e., statistical insights buried in all that telemetry data). Sounds important, right? That’s because it is. As Sigelman went on to explain, monitoring really means “an effort to connect the health of a system component to the health of the business.” That’s always going to be a good idea, and feeds into things like more modern approaches to service-level agreements (SLAs) like service-level objectives (SLOs), an approach that Google has helped to popularize

So why is monitoring suddenly un-cool? Sigelman suggested:

“Monitoring” got a bad name because operators were trying to monitor every possible failure mode of a distributed system. That doesn’t work because there are too many of them. (And that’s why you have too many dashboards at your company.)

Dashboards are nice, but they can also confuse as much as they clarify by bombarding operators with too much data. If we dig into SLOs, however, Sigelman argued that they can help monitoring to evolve beyond noisy dashboards to SLOs that help us gauge the changes in signals that help us track system health.

These SLOs, which set a numerical target for system availability, act as the “peripheral nervous system” of observability, said Sigelman. Rather than relying on a human staring at a dashboard (or, more likely, an array of dashboards) and hoping she can cognitively decipher what’s happening at a glance, the SLO approach instruments things in a way that allows humans before and after the fact to dial up (more cost to operate) or down (lowers costs and increases development velocity) reliability.

So is monitoring dead? Nope. Not even close. Perhaps the way we used to conceive of monitoring is due to be retired, but the practice of monitoring has never been more important. It’s a central component of observability, and likely will be for years to come.

Disclosure: I work for AWS, but the views expressed herein are mine.

0