Relative Content

Tag Archive for linuxbash

find 1 pattern above th initial pattern in a file

In this example I like to find XNAME where its value is equal to “US4” and assign US4 to $VAR1
I can do that using grep and “cut” and “tr” that is not a problem
The problem I have is that I need to find the section where this entry falls under The length of each section differs so are the entries within each section
So in example below once I grep for XAME where XNAME = US4 – I will need to find the section that it belongs to which is TNAME1 and assign TNAME1 to $VAR2
Thx

How to withdraw the previous command in bash

(1)I am learning how to use command in bash.
I excute a command by mistake,and use “mv” wrongly to make some system file into the /tmp dictionary
I search on google but make no sense. Is there any shortcut key like Ctrl+z can withdraw the latest command?