Skip to content
Advertisement

Tag: command-line

How to sort files by word count in linux?

I have to sort files in current directory based on word count by using command wc and pipe | necessarily. What command do I have to use? I thought I had to use a command sort | wc -w, but I failed. Answer I think this can help. The ls -1 will list all files of the current directory, and

jq script file not getting the key/value pair

I would like to put all jq filters inside a text file and use the jq -L option to execute the filters. However, I can’t get this simple thing working. Inside my sample2.json file, I have: Inside my json2csv file, I have: When I do: The output is the whole sample.json file, like this: but I would expect the output

Replacing line of text cointing using sed

I’m trying to replace document.querySelector(‘.popup’).classList.add(‘active’) by document.querySelector(‘.popup’).classList.add(‘noactive’) Answer You can use See the online demo. The regex is POSIX BRE compliant and matches (document.querySelector(‘.popup’).classList.add(‘) – Group 1 (1): a literal document.querySelector(‘.popup’).classList.add(‘ text (active’)) – Group 2 (2): a literal active’) text. Note the capturing groups in a POSIX BRE regex are set with (…). The literal dots need escaping and

Add more new lines to end of line in stdout

I want to be able to print out my logs with extra new lines. This is what the logs look like They look much cluttered in the terminal and although there is a newline, I want to add 1 more newline to make it more readable. I tried using and to no avail. Answer Not entirely certain about portability, but

Advertisement