I’ve been looking all over the internet but had no result. I’m trying to build a package generator (in shell/bash) and that respective package contains (one or more) json files. When browsing through a json file, if the user wants to delete one of the steps I must first take into consideration what if the step he wants to delete
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 dir) to
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 commnand that replaces the string example with an
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
sed/awk – remove a multiline block if it contains multiple patterns
In an xml file a multiline block is identified by <start></start>. I need to find and delete these multiline blocks if they contain a set of pattern in any order (pattern1, pattern2, etc). For example, in the following: if searching for pattern1 only, blocks 1, 3, 4 should be deleted if searching for pattern2 only, blocks 1, 2, 4 should
Sed replace all matches after some patterns
I want to replace all B after ‘=’. The expected result should be But I got this result: Only the last matched pattern be replaced. How to resolve it? Answer Use this sed: Test:
Removing specific string from lines in file using sed
I have a file like so: I want the following output: What I tried is: But this is not what I want… Answer Try this way
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 percentage. When
sed command string variable concatenation within single quotes
I want to modify the include_path directive in my php.ini file using sed. Below, I’ve got a command that looks for a string and places the directive on a line after the match. However, I cannot get it to work while still maintaining the double quotes within the ${install_path} variable. The double quotes must be there. The file I want