![]() |
|
|
|
|
|||||||
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to delete text from line starting pattern1 up to line before pattern2? | repudi8or | Shell Programming and Scripting | 5 | 04-15-2008 06:25 PM |
| how to delete line with matching text and line immediately after | orahi001 | UNIX for Dummies Questions & Answers | 6 | 01-14-2008 08:34 PM |
| delete the last line | srivsn | Shell Programming and Scripting | 3 | 02-07-2006 02:55 AM |
| delete a line based on first character of the line | borncrazy | UNIX for Dummies Questions & Answers | 2 | 12-06-2005 11:27 AM |
| sed 's/~/\^J/g' how to get "^J" on same line as rest of the command. | Optimus_P | UNIX for Dummies Questions & Answers | 6 | 07-19-2001 06:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Delete rest of the line
Hi, can anyone please answer my question in deleting the rest of the line. I have an example below of a file contaning:
Serial3/1.5 43.70.195.13 YES NVRAM down down Serial3/3 225.94.155.69 YES NVRAM up down Serial3/6 unassigned YES NVRAM administratively down down Serial3/7 unassigned YES NVRAM up down ATM2/0 unassigned YES NVRAM up down My question is how do I delete the rest of the line except the first word from each line. My result should be Serial5/1.5 Serial3/3 Serial 3/6 . . . Regards, Aejaz |
| Forum Sponsor | ||
|
|
|
|||
|
Hi,
You'll get the same output using the awk. You can also get the output of first words in firstword.txt your command.... | awk {' print $1'} | tee firstword.txt For example, if you want to get only the first word in uptime. use $ uptime | awk {' print $1'} 01:59:45 |
| Thread Tools | |
| Display Modes | |
|
|