Sponsored Content
Full Discussion: Editing lsblk output
Top Forums Shell Programming and Scripting Editing lsblk output Post 303023094 by JAW on Tuesday 11th of September 2018 09:32:02 PM
Old 09-11-2018
Editing lsblk output

Code:
lsblk -o NAME | grep -A1 -w "sdh" |grep -v "sdh"
└─mpathw


Note the above output

I would like to create variable called $MPATH

echo $MPATH using the input of the above

Code:
echo $MPATH

mpatchw

Basically, I am trying to grab the NAME after the bar/dash configuration

------ Post updated at 09:32 PM ------

Code:
WORK=`lsblk -o NAME | grep -A1 -w "$DISK" |grep -v "$DISK"`
WORK2=${WORK:2}


Figured this out - I was not thinking at the time

Last edited by Scott; 09-12-2018 at 08:57 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Hex editing

Hi, I am new to UNIX. I have a text file where each line ends on the hexadecimal character "0A". In the file there are some records that contain the Hex characters "0D0A" which I need to replace by Hex "20". Is there a simple way to do this? Regards, Swanie (3 Replies)
Discussion started by: Swanie
3 Replies

2. Shell Programming and Scripting

file editing

hi experts, please help me in writting the script.. i have two files file1 and file 2 i have to write a script which will take input parameters as file1 and file2 file1: ...... 1 2 3 4 file2: ..... 1 2 output (6 Replies)
Discussion started by: subhendu81
6 Replies

3. Shell Programming and Scripting

file editing

how to remove duplicate word in a file ? (2 Replies)
Discussion started by: mail2sant
2 Replies

4. Shell Programming and Scripting

Question on vi editing

If I have a text file which I am editing with vi and I perform the following editing. :1,$s/\<green\>/blue/g Later I decide to replace all ocurance of blue to red, then instead of writing the above editing line is there a way to recall it and work on it, instead of repeating the entire editing... (1 Reply)
Discussion started by: Tirmazi
1 Replies

5. Shell Programming and Scripting

substitution without editing

I have a script with 100's of lines in it. I want to edit the script with out manually openning it (with vi editor or some thing like that). Basically I want to do a substitution using regular expression (%s/G_/28_/i). Please let me know the best way to do this. (4 Replies)
Discussion started by: Lucky Ali
4 Replies

6. Shell Programming and Scripting

Need help in editing a file

I have a file which has 10 million records in it. When am trying to edit the file with vi, the following error occurs: ~ ~ ~ ~ ~ ~ ~ ~ "file1" Value too large for defined data type Is there any way that I can edit this file without using vi? Any help would be really appreciated.... (8 Replies)
Discussion started by: bobby1015
8 Replies

7. Shell Programming and Scripting

input a file editing it, output it.

i have a file that contains such earthquake data, i want to write an AWK or SED script to input it and fix it (delete each section header delete some field, delete some blank lines and put ### instead of that) and at the end output it to a new file. here is my file: EventID Date (UTC)... (2 Replies)
Discussion started by: oreka18
2 Replies

8. UNIX for Dummies Questions & Answers

Help with editing columns

Hi, I have large file with 3 columns and want to output the 1st and 2nd column only. However I want the 2nd column to be edited like this: 14.036 to fx14 (notice the number in fx14 comes from the first two digits of 14.036) BEFORE: aran24352 14.036 14.036 aran08740 07.034 07.032... (3 Replies)
Discussion started by: narachaid
3 Replies

9. Shell Programming and Scripting

Convert vi editing to text editing

Dear Guru's I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response. Srini (6 Replies)
Discussion started by: thummi9090
6 Replies

10. UNIX for Beginners Questions & Answers

Grep mpath disk name from lsblk command

When I use lsblk | tail -1 | awk -F " " '{print $1}' command and if a disk is a multipath I get output as └─mpathe But i need only mpathe to be grepped as output.. Please help.. But It works well if the disk is not mpath (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
ZGREP(1)                                                      General Commands Manual                                                     ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 06:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy