2
votes
2answers
40 views

How to find frequency of occurrences of strings contained in a file?

I have a file that contains a list of URLs of the form http://www.google.com, www.google.com, google.com yahoo.com I want to write a script that will display the following output ...
3
votes
2answers
80 views

Bash-script. Shift seconds

Maybe somebody can help me. In bash I don't know how to do that. I need to do a bash-script. At stdin I have .srt file of subtitles in this format: num HH:MM:SS,SSS --> HH:MM:SS,SSS text line 1 ...
4
votes
4answers
140 views

How do I aggregate data from many files into one file?

I have this directory structure for about 100 users. users - user1 - info.txt - user2 - info.txt - user3 - info.txt ... Inside the info.txt files, the contents look like this. 5 ...
3
votes
3answers
111 views

Transforming text to tabular form

I have a text file with the following structure: aaa bbb ccc ddd eee fff 1 2 3 4 5 6 1.1 1.2 1.3 1.4 1.5 1.6 ggg hhh iii jjj kkk lll 7 8 9 10 11 12 2.1 2.2 2.3 2.4 2.5 2.6 and I want the ...
3
votes
5answers
92 views

Comparing Indices of two strings

I have two double quoted strings of same length, that look like this: "$con" - (consists of spaces and *'s): * ****** *** ** * ** and ...
4
votes
1answer
87 views

Looking for lines which is in one file but not in other using Unix and Awk

I have 2 files with 7 fields and I want to print the lines which are present in file1 but not in file2 based on field1 and field2. Logic: I want to print all the lines, where there is a particular ...
0
votes
2answers
96 views

Couting all characters by BASH character class

I need to efficiently count every character of an arbitrary file by its character CLASS (as defined by the BASH man page); i.e. [[:alnum:]], [[:alpha:]], [[:ascii:]], [[:blank:]], [[:cntrl:]], ...
2
votes
6answers
113 views

Bash - Split the previous commands parameters

How would one parse the previous command in bash? Example: root$ ssh [email protected] root$ echo !$ &>/tmp/foo.txt root$ cat /tmp/foo.txt [email protected] Goal: Send just the ipaddress 1.2.3.4 to ...
3
votes
1answer
125 views

convert bulk of text files to pdf with naming based upon header file

Knowing that "How to convert from text to .pdf" is already well answered here link and here link, I am looking for something more specific: Using Claws-Mail [website] and a Plug-In [RSSyl] to read ...
6
votes
7answers
800 views

How to test whether the file is crlf or lf without modyfing it?

I need to periodically run a command, that ensures that some text files are kept in linux mode. Unfortunately dos2unix always modifies file, which would mess file's and folder's timestamp and cause ...
3
votes
3answers
234 views

Editing config file via a bash script

I've been trying to write a simple bash script which I'll be using to install an application and update it's config file. I'm having hard time to have get it's config file modified. # ...
4
votes
6answers
120 views

Getting two fields from same line together

I've got a situation where I've got several lines, and I need two different fields out of each of them. To be specific, I have a list of references in a bibliography and I want to get the last name ...
1
vote
2answers
130 views

How to record every transaction using Bash

I have a file with debit credit and withdrawal transactions. I need a bash script that records the balance after every transaction. So file is like this: D:11/02/12:1000.50 C:11/03/12:300 ...
1
vote
4answers
861 views

print last field from line + alternative for awk

Due to technical reason on my Solaris machine, I can't use awk in order to print the last field in line. What are the other alternatives to awk that print the last field from line (using cut or tr ...
11
votes
4answers
368 views

How to do a continous 'wc -l' with gnu texttools?

I know of course that cat logfile.txt | wc -l 120 will tell me the number of lines in a file. Whereas tail -f logfile.txt will show me the new lines that another program writes to logfile.txt. ...
4
votes
2answers
384 views

Why doesn't this xargs command work?

I wanted to delete all .sh extensions so did this: ls *.sh | xargs -I {} mv {} `basename {} .sh` However it doesn't work, it behaves like basename returns unchanged file name. Why is it behaving ...
3
votes
3answers
52 views

How to separate numerical values from identifiers

I'm currently writing a shell script that seperate values from their identifiers (retrieved from grep). For example, if I grep a certain file I will retrieve the following information: value1 = 1 ...
5
votes
1answer
104 views

array[@] output all messed up?

I've got this code: Unix+=("Stock List") while read line; do result=$(wget -O - -o /dev/null "http://finance.yahoo.com/d/quotes.csv?s=$line&f=sl1&e=.csv" | tr ',' ' ' | tr '"' ' ') ...
3
votes
1answer
120 views

Printing the line after or before a regular expression match in Bash

Given a string like the following: BASH - Mplayer Playlist Shuffle http://www.youtube.com/watch?v=IB7SCPtbJM8 metalx1000 BASH - Playing Music http://www.youtube.com/watch?v=S_-EGoLYCXY metalx1000 ...
2
votes
2answers
180 views

How to read by multiple lines instead of line-by-line

I see that in my code I can modify a line if the entire code is based on that line. Example: <p class="example">this is an example Happy Holidays</p>. However if the </p> tag is ...
4
votes
2answers
603 views

How to delete commands in history matching a given string?

I need to delete all commands in my history matching a string. I've tried: $ history | grep searchstring | cut -d" " -f2 | history -d -bash: history: -d: option requires an argument $ history | grep ...
2
votes
3answers
503 views

Substitute placeholders in template

Say I have a shell configuration file config like this: HOST=localhost PORT=8080 Now I have a template template like this: The host is <%= @HOST %> The port is <%= @PORT %> How do I ...
3
votes
2answers
220 views

Limit stdout from a continuously running process

I haven't had much luck finding an answer to my problem, but maybe I'm not asking for it correctly. I have a process I startup like the following: nohup ping 127.0.0.1 > log.txt >2>&1 & ...
0
votes
2answers
179 views

Easiest way to find/replace in a file using a list?

I have a file, foo.txt, and a regexp I want to find in that file. Each time I find the regexp, I want to take a line from another file, bar.txt, and substitute it in for the regexp match I found in ...
0
votes
1answer
287 views

Remove a block of lines between two patterns [duplicate]

Possible Duplicate: Show only text between 2 matching pattern In a bash script using sed how can I remove a block of lines beginning with -pattern a- and ending with -pattern b- where the ...
2
votes
4answers
473 views

How to do an IF statement from the result of a executed command

I am trying to do an IF statement from the output of an executed commmand. Here is how I am trying to do it, but it doesn't work. Does anyone know the right way to do this? if [ "`netstat -lnp | ...
6
votes
6answers
2k views

Text processing - join lines with commas

I have more than 1000 lines in a file. The file starts as follows (line numbers added): 1. Station Name 2. Station Code 3. A N DEV NAGAR 4. ACND 5. ABHAIPUR 6. AHA 7. ABOHAR 8. ABS 9. ABU ROAD 10. ...
2
votes
5answers
3k views

Bash iterate over a list of strings

I have this bash script: for opt in string1 string2 string3 ... string99 do somestuff It works, but I would like to replace the explicit listing of my strings with a file which actually contains ...
9
votes
5answers
254 views

How to count rows ordered by the first field in bash

Here is a snippet from the INPUT: ... #################### Bala Bela;XXXXXX12345;XXXXXX12345678;A SERVER345Z3.DOMAIN.com0 SERVER346Z3.DOMAIN.com0 SERVER347Z3.DOMAIN.com0 SERVER348Z3.DOMAIN.com0 ...
4
votes
6answers
270 views

What is the easiest way to check if column A and B values goes both ways with AWK? [closed]

What is the easiest way to check if column A and B values goes both ways? Output to check: Mike John John Mike Pamela Barbara Barbara Pamela Mike Paul Roger Paul Desired output Mike <-> ...

15 30 50 per page