Skip to main content

All Questions

Tagged with
6 votes
2 answers
596 views

How can I extract quoted strings within a variable?

I acknowledge there are superficially similar questions asked here before, but all of those I've seen are simpler than what I'm trying to achieve. Bash-only solutions are preferred. I have a variable ...
user648855's user avatar
2 votes
2 answers
969 views

Why is the file changing before being written to?

On Kubuntu Linux, The Google Chrome browser adds a checksum to the file, preventing simply editing the file by hand. So I'm writing a script to add the checksum. $ cat .config/google-chrome/Default/...
dotancohen's user avatar
  • 16.4k
-2 votes
3 answers
139 views

How to replace two lines containing [tab] chars into one line with just [newline] char, using a bash script?

In a directory I have a bunch of text files. Some of the files contain double lines with a [tab] char only. I want to find and change these two "tabbed lines" into one line with a new line ...
ludvick's user avatar
  • 21
-5 votes
2 answers
81 views

How to count the no of occurrences of a particular string in a latest log file to read last 5 min data in linux [closed]

I want to capture an error code (e.g. 502) from a log file. The log file is rollover when it's reached to 100 MB like access.log_126427, access.log_197455, etc. There is no specific pattern of the ...
Ajit Kumar Panda's user avatar
0 votes
1 answer
115 views

Find all files in directory and apply commands to each of them

I want to apply commands below to all files in a directory instead of one file. cat file.txt | sed -E "s/\@([0-9]+)\W+~(.*?)/\1 \2/g" | tr -d '~' cat file.txt | sed -E "s/\@([0-9]+).*\~...
user1002601's user avatar
-1 votes
2 answers
167 views

Finding number of occurences of a word in a PDF file

Inside a folder there are plenty of subfolders and inside the subfolders there are plenty of PDF files. Looks like below: +- SubfolderA | +- File1.pdf | +- File2.pdf | +- SubfolderB | +- File3.pdf |...
Ronnie's user avatar
  • 29
2 votes
5 answers
531 views

Move line matching string to top of the file

Need to move single line with PRM:TRG keyword to top of the file using sed File content: FOOBAR:SCN:NO_TRG FIZZBAR:SCN:NO_TRG BEBAR:PRM:TRG Output expected: BEBAR:PRM:TRG FOOBAR:SCN:NO_TRG FIZZBAR:...
netdis's user avatar
  • 131
0 votes
3 answers
102 views

Splitting Words into space separated characters [duplicate]

I have a table with one word in each row. I want to split the word into space separated c h a r a c t e r s. Is there a way to do that via bash command? If yes, I also have a table with multiple words ...
Daniel Capkan SamuriLPT's user avatar
0 votes
3 answers
88 views

Need to make multiple multiline replacements in file

I have a file with multiple "paragraphs" like this: <type>TRANS</type> <attributes/> <specification_method>rep_name</specification_method> <trans_object_id/&...
Todd Porter's user avatar
-1 votes
1 answer
69 views

how to omit/ignore/remove lines starting with local/ using awk

Variable _RESULT contains an output of pacinfo --verbose local/jre. Using awk script (by Ed Morton - thanks to him!): awk '{ match($0,/:[[:space:]]*/) nextTag = substr($0,1,RSTART-1) ...
ludvick's user avatar
  • 21
0 votes
1 answer
63 views

Append the arguments to a script as lines in a file

How do you append $@ or $* , each as a new line to a file? I think I already searched for that before. Adding a new option -i --insert-newline with possible values 1, 2, 3 or Linux, Windows, Mac to ...
Laurent Lyaudet's user avatar
0 votes
1 answer
57 views

Replacing variable correctly in alias function

I'm trying to create an alias function to remove inputted line from file: function remove_line(){ line_to_remove="'s/^"$1"$//g'" sed -i $(line_to_remove) my_file } ...
ellat's user avatar
  • 137
-2 votes
1 answer
182 views

Error in command su

I am creating a command that will change a certain line in the /etc/profile file from a script, however in certain versions of Linux the sudo command may not be activated so it would be necessary to ...
user avatar
2 votes
7 answers
2k views

How to remove embedded newlines from CSV fields

I am struggling with processing a file. Normally I should have a line for each host definition. But sometimes, someone split some fields on different lines. Here is an example: "host1","...
Nicolas Greder's user avatar
2 votes
1 answer
87 views

Playing random videos on one's system; minor improvement to include DVDs

In my .bashrc I have a function which I use to play random videos (not written below, just fyi), and another one for all media files, e.g.: createmediafiles() { find ~+ -type f -iregex '.*\.\(mp3\|wav\...
1toneboy's user avatar
  • 465

15 30 50 per page
1
2 3 4 5
49