Skip to content

Tag: bash

How to extract something out of a file after greping?

How can I extract group-3-vm1 after I do this grep? Here’s the result: Answer This awk command replaces the grep and tail commands while also extracting the text of interest: How it works -F'[:/]’ This sets the field separator to either a colon or a slash. /Tracking URL/{n=$4;} This looks for line…

Embedding bash commands

I’m using virtualenvwrapper and trying to create a virtualenv using a version of python that’s not the default. What I’d like to do is: …But without the copy-paste. Is there a way to do this in one line? Answer is the correct way to write this as a one-liner. type is a POSIX standard u…

linux terminal text manipulation

I am now studying linux command line and this question is in my head for almost a week but i think still i have not found optimal solution, question is next: i have file with is formatted in a bad way one word on each line: as you see those are linux distros with version and release dates right formatting

Grep regexp for matching ip addresses in a file

I’m trying to search a file “Sessions” that contains IP addresses (among other useless junk). My Grep is failing to match, even though REGEXR is matching perfectly all the IPs perfectly … so I know the REGEX is correct … but when I GREP for this same pattern, not is returned. I&#…

Bash – Delete lines ending with a number

I need to remove only lines (in text file) ending with a number. Before: After: Answer Since you’re referencing my favorite movie, I’ll answer: Which translates to: Delete any line where there is either a space or a tab, followed by at least one digit, then any amount of spaces or tabs at the end …

Grabbing data between two commas

I am in the process of writing a simple script to grab battery information from acpi so I can format and output it. Currently, I am using cut to grab this information, but as the battery state changes, cut does not grab the correct data and instead will grab a portion of a string instead of the battery percen…

Adding server hostname to each line of ‘find’ output

I am in need of a listing of all files with a specific extension on a server. I need it to show the server hostname, file size, and absolute path of the file. or Almost get me there: joes_server 5473 /home/joe/pics/sunset.jpg 8522 /home/joe/pics/mountains.jpg I cannot figure out how to include the hostname on…