All Questions
11 questions
1
vote
2
answers
2k
views
How to remove all spaces at the end of strings in a text file in linux
I have file named a.txt and it contains strings but got some additional spaces at the end
cat -vet a.txt displays
ab cd^M$
abcdefg ^M$ //there is a space at the end
aaaaaaa^M$
bbbbbbb^I^M$ //there ...
0
votes
1
answer
77
views
awk comparison on Ubuntu
I'm trying to write a script that check the disk usage of remote clients. There is a filter in script for meaningful output:
...
ssh server "sudo df -Ph 2>/dev/null \
| tail -n +2 \
| grep -v ...
2
votes
2
answers
236
views
Find Missing Numbers
I have a big list of files with names (videos)
I managed to write all file names in a text file. Now I have a text file with a lot of file names (one episode per line)
Now I need something that can ...
0
votes
1
answer
134
views
How to use sed to remove "(double-quotes) on code lines while leaving them on real comment lines in a vimrc file?
On Ubuntu(Server/Desktop), I wish to remove a single " (double quotes) character from the beginning of lines in my /etc/vim/vimrc.
This should be done for all lines that start with a ", but not if ...
3
votes
1
answer
100
views
Add specific text in every blank line
I've a file as below
abc
pqr
xyz
aaa
bbb
ccc
I want to add specific text like "this is test" in every blank line like below
abc
this is test
pqr
xyz
this is test
this is test
aaa
bbb
this is ...
0
votes
1
answer
34
views
Shell Script to look for all lines in a file having '500' in the 11 column taking too long to run
I wrote the following script as a practice :
#!/bin/bash
MyFile=$1
while read p; do
error=$(echo $p | awk '{print $11}')
if [ "$error" = "500" ]
then
echo $p
...
4
votes
1
answer
1k
views
Using sed to compact JSON arrays
I have a JSON output in the following format:
{
"DaysCfg": {
"Range": {
"lowerDate": "2017-07-28T00:00:00.000-04:00",
"upperDate": "2017-08-04T00:00:00.000-04:00"
},
"...
1
vote
1
answer
1k
views
For each output of grep execute multiple commands
First:
sudo netstat -nptc | grep -oP "\K[0-9]*(?=/perl)"
The above gives me the pid as they are started, so it is constantly running.
Second:
For each output of the first command above I want to ...
0
votes
2
answers
209
views
Trying to get example from Awk and Sed book to work on Ubuntu 13.04
I have been developing Windows Software for years. I am trying to branch out and learn Linux. It will really help with my new job.
I have picked up the book, "Awk and Sed" 2nd Edition. I am ...
0
votes
1
answer
503
views
Can't use awk in terminal
I want to use awk command to do something,
I input awk in terminal,
but the terminal show me that
awk: cannot open /home/user/myexe/external_symbols.awk (No such file
or directory)
Someone tell ...
2
votes
2
answers
784
views
Count elements in lines with awk
I have a tab-delimited text file containing data like
Col 1 Col 2
1 a
1 b
1 c
1 d
1 d
2 a
2 b
3 a
so on and so forth.
I would like to transform this structure into
...