Editing lsblk output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Editing lsblk output
# 1  
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..
# 2  
Old 09-12-2018
Hi,
why do you not use option -r of the command lsblk like this ? :
Code:
lsblk -ro NAME | grep -A1 -w "$DISK" |grep -v "$DISK"

Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. Shell Programming and Scripting

file editing

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

9. 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

10. 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
Login or Register to Ask a Question