1
vote
2answers
54 views

Editing a Java properties file with Bash

I have the following Java properties file that is maintained by humans. # file.input = /very/old/name # file.input = /old/name file.input = /current/name file.input.default = /default/name ...
1
vote
2answers
43 views

Bash: split list of files into different files?

I have several files in a directory like: data1.dat data2.dat .... data24678.dat To run another code, I need to have a text file with the names of the files but I need to split in 50 files per ...
1
vote
4answers
95 views

How can I delete the first dot before the first number?

How to remove the first dot before the first number? For example I have the following file more file Version …………2.465.76.8.332 I want to get only the version number - 2.465768.332
4
votes
2answers
125 views

How can I delete all unordered lines from a text file?

Overview Consider an ordered list interspersed with unordered elements, e.g.: Alligator Ant Falcon <-- Baboon Badger Armadillo <-- Caiman Cat How can this list be processed so that all ...
5
votes
1answer
94 views

counting multiple patterns in a single pass with grep?

I've written a grep loop to iteratively count DNA trinucleotides within a gzipped DNA fasta file containing DNA sequences e.g. declare -a tri=(AAA AAC AAG AAT CAA .. etc) for i in ${tri[@]} do ...
-1
votes
1answer
49 views

Importing an excerpt from a file into a script

I'm trying to import an excerpt from a file into a script for processing. LIST=$(sed '1,/+++NETWORKLIST+++/d' < /path/to/file | sort -t ";" -k2,2r) My problem is that this script is not deleting ...
3
votes
4answers
75 views

Replace all newlines to space except the last

How can I replace all newlines with space except the last newline. I can replace all newline to space using tr but how I can do it with some exceptions?
0
votes
1answer
102 views

How to print gmail inbox messages

I want to print inbox messages one by one (like cat someFile) so that I can parse the message contents. something like printGmail InboxMesg1 | grep some | sed some Using curl I can access the ...
1
vote
1answer
128 views

Problem with sed on a array containing strings containing spaces

I have a array looking like this: array=("(1 2 3) (123)" "2 31 (231)" "4 5 1 (451)" "(te)xt (1234)") This array is a example. It does not look like this but its structure is the same (the strings ...
4
votes
3answers
119 views

Parsing string token with bash

I have this output (from a previous command): aaa something bbb someother ccc blabla For each line, I would like to create a file whose name is the first token, and whose ...
0
votes
1answer
102 views

Copy file while replacing text in it

I'm writing a script to publish a webapp. While copying files, I must replace a placeholder current_date in a file with the current date. I would start with something like this to define the date ...
2
votes
6answers
1k views

bash - replace space with new line

How can I replace spaces with new lines on an input like: /path/to/file /path/to/file2 /path/to/file3 /path/to/file4 /path/to/file5 etc... To obtain the following: /path/to/file /path/to/file2 ...
2
votes
2answers
692 views

Convert csv to HTML table

I have a Medical.csv file with rows of following format, field: 'participation.type', displayName: 'program_type', type: 'String',path:'participation' field: 'participation.program', ...
8
votes
4answers
172 views

Split the file and put it in corresponding data structure?

I have a file which contains the single line below: {machineA=[0, 1024, 4, 1028], machineB=[1, 1025, 5, 1029]} in which I have two datasets: machineA=[0, 1024, 4, 1028] machineB=[1, 1025, 5, 1029] ...
1
vote
3answers
185 views

remove particular characters from a variable using bash

I want to parse a variable (in my case it's development kit version) to make it dot(.) free. If version='2.3.3', desired output is 233. I tried as below, but it requires . to be replaced with another ...
5
votes
5answers
502 views

Parsing a delimited text file in bash as command arguments

I have a text file split up like so: field1,field2,field3 xield1,xield2,xield3 dield1,dield2,dield3 gield1,gield2,gield3 Each of these columns will be a parameter to a program, and I would like ...
2
votes
2answers
115 views

stripping out the last two [end] with sed?

I'm working on a script that improves the fluxbox 'menu', and my script has this line: sed -i 's/\[end]//g' ~/.fluxbox/menu;sed -i '/^\s*$/d' ~/.fluxbox/menu but this has the unfortunate effect of ...
2
votes
5answers
105 views

Read contents in a line in bash

I have a file with contents in this order which is separated by space 4096 1230 4560 1024.... n How can i read each number and pass it on to another command, eg divide each number by 1024.
2
votes
2answers
1k views

Insert text in specific lines of a file?

How can insert some text in specific lines of a file? What is most simplest method that I can use? (bash, sed, awk?) What I want to do, might be simple, but I don't know where I should start. It's ...
3
votes
2answers
177 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 EDIT http://www.google.com/absd/siidfs/kfd837382$%^$&, www.google.com, google.com yahoo.com/list/page/jhfjkshdjf... I ...
3
votes
2answers
158 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
169 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
138 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
167 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
102 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
162 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
149 views

Bash - Split the previous commands parameters

How would one parse the previous command in bash? Example: root$ ssh foo@1.2.3.4 root$ echo !$ &>/tmp/foo.txt root$ cat /tmp/foo.txt foo@1.2.3.4 Goal: Send just the ipaddress 1.2.3.4 to ...
3
votes
1answer
226 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
2k 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
1k 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
138 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
146 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 ...
2
votes
4answers
2k 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
602 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
775 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
60 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
117 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
156 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
210 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
1k 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
771 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
339 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
217 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
341 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
1k 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 | ...
7
votes
7answers
3k 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
5k 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
275 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
313 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 <-> ...
4
votes
2answers
1k views

delete first line of file only if blank using sed

I have a solution for this in awk: awk '{if (NR==1 && NF==0) next};1' somefile but was unable to find one that worked in sed. E.g., sed -i.bak '/^$/{1,1d;}' somefile ended up deleting ...