Skip to content

Tag: sed

SED : Remove last four characters from filename

I had list of files in the folder named test_images as below i want to rename all file by removing last four characters from each of them as How can i do it using sed ? Any suggestion will be appreciated. Thanks in advance 🙂 Answer if your file names don’t have spaces, you can: (under your test_images d…

sed removes one string in one file

I’m trying to remove one string in one file by using: But I’ve got the following error: What is it missing and why? Thanks! Answer /example/ is an address which tells sed where to run commands – on a line containing the string example. You didn’t specify any commands. This is a commnan…

awk sep data extracting lines after certain variable

I have a large file that has some regular pattern These line are repeated among other lines above and below. I need to print the snaps1 line and also get the instance: line So I need to search for snaps1 but only if counter is greater than 0 and then print snaps1 line and also the instance line. Sorry have

Shell : choosing string between two strings using sed

I have a log file in format like this : I want to return all the strings which are between pseudo and pseudoConcat, my desired output is : How can I do this using sed or awk? I’m trying for a few days in vain. Thanks. Answer With GNU grep: Output without trailing spaces: thierry33 i love you With bash:

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…