Tagged Questions
2
votes
3answers
61 views
Scripting to domain allocation to server
I have two text files:
file #1: domain.txt
cocacola.com
airtel.com
pepsi.com
file #2: servers.txt
192.0.53.42 , 4 # 4 domains already allocated on server 192.0.53.42
192.53.1.2 , 1 # 1 ...
3
votes
1answer
41 views
How to edit files in-place while performing operation on the values matching the searched pattern?
Given a list files containing random text and many datetimes in ISO format in it (e.g "2012-07-02T10:47:24+02:00"), how can I find all these datetimes and add 2 hours to each one ?
Ideally a solution ...
0
votes
1answer
150 views
How can I find and filter a specific column in a .csv file? [duplicate]
I have .csv files with the following structure:
cat,dog,mouse,pig,bird,cow,...
21,34,54,566,78,1,...
23,10,12,569,56,4,...
32,20,13,123,56,3,...
34,30,44,322,66,2,...
I want to filter the column ...
3
votes
2answers
68 views
Comparing two columns with two columns
I have a file that I need to compare the values in two columns with another two columns. For examples:
Item A B C D
1 201 3101 3101 201
2 3101 201 202 3101
3 3101 201 ...
2
votes
5answers
456 views
How can I split a text file into multiple text files using Perl?
I have a file ABC_TabDelim.txt that contains the following:
00:00:00:00 00:00:05:00 01SC_001.jpg
00:00:14:29 00:00:19:29 01SC_002.jpg
00:01:07:20 00:01:12:20 01SC_003.jpg
00:00:00:00 00:00:03:25 ...
1
vote
1answer
126 views
How to match 2 large file and print the difference in shell script
I have 2 files.
File1 has 400k numerical records.
e.g:
1
2
3
4
5
6
.. and so on
File 2 also has 420k numerical records.
e.g:
1
2
3
4
6
.. and so on
Both these file are in unsorted manner. I want ...
2
votes
2answers
213 views
System calls, AWK, and Bringing in external inputs
awk '{ TEMPVAR="/usr/bin"; printf("%s", system("ls $TEMPVAR")); }' empty
In this example I'm trying to bring in the variable TEMPVAR into the system call. How would I do this?
What I'm aiming to ...
16
votes
1answer
502 views
How to implement a horizontal cat?
Standard cat concatenates files line by line (row by row, if you will). I find myself needing a horizontal cat command more and more often recently; i.e. a command that takes a list of files and ...
2
votes
2answers
220 views
How to traverse a file and extract words using their index?
The given file must not be stored in variable and then traversed due to memory size restrictions:
Example:
var=$(cat FILE)
for i in $var
do
echo $i
done
How do you traverse all strings in a file ...
2
votes
1answer
189 views
intersection of two files according to the first column
I have two files
in file A, there are sequence_numbers
in the other file B, there are many columns, and the first column is sequnce numbers,
I want to get a files with all the lines in the B with the ...
1
vote
1answer
101 views
Using join with two files fails on larger file sizes
I am having some issues with a script that is using join to join two files. Eaxmple input files contains lines like this:
Here are the input file and the output of the join command:
...
3
votes
3answers
181 views
How to make and apply (patch) one side diff?
I want to make a shell script that updates a config file.
The file present on the server has information, like various IP addresses.
The new file has more code, from new configs added to the system, ...
9
votes
6answers
600 views
Text Manipulation Across multiple lines
I Have a file that has text like this:
AAAA
BBBB
CCCC
DDDD
1234
5678
9012
3456
EEEE
7890
etc...
And i want to match up the Alphabetic lines with the Numeric lines so they are like this:
...
2
votes
3answers
273 views
dynamic display of a running process?
I am writing a script and acording to that when i run it certain info will be displayed on the output screen.
for example say the constant data displayed is:
my name is mukesh.
i am 27 years old
...
1
vote
3answers
384 views
To list out duplicate filenames in a listing?
bash-3.00$ cat f.txt
-rw-r--r-- 1 mukesh other 102 Nov 5 18:32 f1.txt
-rw-r--r-- 1 mukesh other 19 Nov 5 18:32 f2.txt
-rw-r--r-- 1 mukesh other 204 Nov 5 18:32 ...
0
votes
1answer
196 views
Making a simple PHP script process text in a pipe
Last week I wanted to convert some simplified Chinese characters into traditional ones. I found a deceptively nice looking shell one-liner, which today I found out was 20% error prone.
So I did some ...
2
votes
2answers
206 views
Comparing files and their properties
I get information of a certain set of files in my mail every day, which looks like this:
58623208 Sep 14 20:08 blbn_blfbe_drv
57904920 Sep 14 19:54 blbn_cycmn
55814208 Sep 14 06:02 clsa_Upd
38912000 ...
3
votes
1answer
141 views
Help improving my AWK skills
This program works as I intended but I feel like I used some clumsy methods to get the out put I desired(especially with my use of print commands and variable declarations)
Could some one improve ...
3
votes
2answers
533 views
How to do a text replacement in a big folder hierarchy?
I want to search and replace some text in a large set of files excluding some instances. For each line, I want a prompt asking me if I need to replace that line or not.
Something similar to vim's ...
3
votes
4answers
585 views
Replacing text from a list of replacements. Added complication: backslashes
I have a file A that contains pairs of strings, one per line:
\old1 \new1
\old2 \new2
.....
I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
2
votes
6answers
2k views
get numeric ASCII value for a character
I'm trying to write a shell script which asks for an ASCII character in the range A-Z or a-z and returns its equivalent numerical value. For example, the output might look like the following:
...
16
votes
7answers
20k views
Looping through files with spaces in the names?
I wrote the following script to diff the outputs of two directores with all the same files in them as such:
#!/bin/bash
for file in `find . -name "*.csv"`
do
echo "file = $file";
diff ...
