Tagged Questions
0
votes
3answers
360 views
compare two files based on a column and print it
I have two big files of 400,000 lines. I want to compare the column 1 of the second file with column 1 of first file recursively. If they match I would like to print the whole line. It is a sorted ...
1
vote
3answers
384 views
compare two columns of different files and print if it matches
I am using solaris 10 and Grep options involving -f doesnt work .
I have two pipe separated files:
file1:
abc|123|BNY|apple|
cab|234|cyx|orange|
def|kumar|pki|bird|
file 2 :
abc|123|
...
3
votes
5answers
126 views
Get values block by block in same file
I have a file say "SAMPLE.txt" with following content,
P1
10,9:6/123456
P2
blah blah
P1
10,9:5/98765
P2
blah
blah
P1
blah blah
P2
I want a output file say "RESULT.txt" as,
Value1:123456
...
1
vote
1answer
55 views
Using kornshell or Perl to circumvent permissions needed by root
I have a problem where I need to change the ownership and permissions of one file that exists on more than 200 servers. I belong to 2 different groups and need to change the ownership from one group ...
4
votes
7answers
322 views
How can I groups numbers in a file
I have a file with numbers in float format.
I can review them via sort -rn numbers.txt | less
I would like though to be able to "group" them. I.e. easily see how many are in the same range.
To give an ...
3
votes
1answer
154 views
Interpret an interpolated variable as a literal string in Perl regex
I am using perl to colorize a matched string
MATCH=aaa
printf "aaa\n/dev/aaa\nccc\n" | perl -pe "s/($MATCH)/\e[1;31m\1\e[0m/g"
This works well until I try to match a string containing special ...
2
votes
3answers
187 views
replace column of a csv file with column from another file
I have two sample files like this:
$ cat file1
abc,sachin
cat,kumar
$ cat file2
xyz
pressure
$ cat file3
xyz,sachin
pressure, kumar
I want the first column of file1 to be replaced with file2.
...
6
votes
3answers
173 views
What is the difference between invoking a perl script via sh or perl
I have a simple Hello World perl script.
#!/usr/bin/perl
print 'Hello world.';
It works fine if I run it via perl <file_name>, but it fails I run it via sh <file_name>.
My ...
1
vote
0answers
67 views
Better approach to generating and adding contents to files
I have an input file like below.
1 First one
2 First two
3 First three
3 Second three
I am generating 2 output files like below.
#FILE1
1 First one
2 First two
3 First three
#FILE2
1 ...
0
votes
3answers
78 views
remove new lines
My input is a csv file like this:
10,"Special Projects,bangaram",0,,0
10,"Statutory/ Internal Audit , MO reporting (incl Excel Spreadsheet uploadation)
", bangaram,0,,0
10,"Complience with ...
4
votes
2answers
133 views
run perl script with unknown perl location
I'm developing a perl script which expected to be downloaded by Mac users with a very small knowledge of shell, linux etc, let's say office managers and accountants.
After the downloading the script ...
2
votes
1answer
49 views
Count and merge consecutive patterns
I'm searching for a short snippet to find, count and merge consecutive duplicates using standard tools or a common scripting language.
Say our input is:
1 2 2 2 7 22 a b b c c c c c d dd 2 2 c c
...
0
votes
2answers
85 views
Merging two different files with conditions
I have two different files as shown below.
Content of a.txt:
HDR|1||||||||||
DTL|@|||||||||||
TLR|||||||||||||
HDR|1||||||||||||
...
0
votes
2answers
102 views
How to Lookup the values of an index values from a big data file?
I have a data file (data_array.txt in the example) and index file, index.txt, at which I want to extract the data from the data file that have the same ID in the index file and store in to a new file, ...
1
vote
1answer
114 views
Parsing the headers of sequence file
I have a multiple sequence file as
>abc|d017961
sequence1......
>cdf|rhtdm9
sequence2......
>ijm|smthr12
sequence3......
>abc|d011wejr
sequence4......
>stg|eethwe77
sequence5......
...
1
vote
2answers
521 views
squid access.log delete entries older than 6 months
Squid generates a log of the accessed sites by the users.
I want to delete the entries in the /var/squid/logs/access.log, which are older than 6 months.
I would execute the script each week. I have ...
0
votes
1answer
503 views
Automation tasks for system administrators [closed]
If I am a junior UNIX/Linux system administrator, and I want to make automation tasks for the server.
I know Shell script, Perl, and Python. All of these are used to make automation tasks.
Which one ...
2
votes
1answer
227 views
how to replace IP address on remote host using expect
I wrote the following expect script in order to replace the IP address on remote Linux machine
I use a perl one-liner for this task
I get errors about can't read "HOME": no such variable ,
Please ...
2
votes
2answers
132 views
ksh + delete number from string
the string IP include some IP address numbers
as the following example
echo ${IP[*]}
192.9.200.1 192.9.200.2 192.9.200.3
is it possible to remove some IP address number from the list ( using ksh ...
1
vote
2answers
234 views
perl one liner + how to match IP address that located in the first/sec field of file
the following perl one liner syntax verify if IP address in "$IP" match the IP ADDRESS in file
perl -ne 'BEGIN{$IP=shift} print if /(^|\s)\Q$IP\E(\s|$)/;' $IP file
file have two fields
as the ...
0
votes
2answers
101 views
perl one liner + print VALUE in the end of the line
The following perl one liner checks if $CURRENT_VERSION matches $NEW_VERSION exactly, and prints it if it does.
Example:
CURRENT_VERSION=223.3.12.4.5.3
NEW_VERSION=223.3.12.4.5.3
DATE=17.3.2013
...
2
votes
1answer
203 views
perl + combine exec command with perl one liner line
I have the following short perl script rename.pl. How can I translate this script to one liner perl syntax? And how to combine the perl one liner in find command?
rename.pl
#!/usr/bin/perl
$op = ...
1
vote
2answers
100 views
renaming a directory and its subdirs without affecting their files
I have to rename directories under the root directory with prefix "ms_PF" and then rename their subdirectories with the modified name of the main directory with an extra "_", and then copy all ...
1
vote
1answer
621 views
Identify text/ascii files in Linux/Solaris
I have a little project to build bash script that search in the OS ( Linux/Solaris ) the current IP address from files and replace them with other IP address.
The problem is that IP address could be ...
1
vote
3answers
521 views
linux/solaris + verify duplicate valid IP address from file
what the best way to find duplicate IP from file ( I have ksh script in this script I need to write function that check for duplicate IP )
for example if IP - 192.1926.23.52 exists twice in file - ...
0
votes
1answer
374 views
linux + perl + replace any WORD in file with special characters with condition
Example1 work fine when I want to replace OLD_TEXT with NEW_TEXT ( its replace also all special characters as $@^%)(_+`:; etc ..)
example1
export OLD_TEXT='$$OLD_WORD$$'
export ...
1
vote
1answer
565 views
Linux + replace STRING/WORD in file according to rule
My target is to replace any word/string/Any characters in file
with new word/string according to the following rules:
If numeric characters on the left side of word/string then we not replace the ...
1
vote
2answers
582 views
What scripting language or platform to use for web page downloads and screen interaction? [duplicate]
Possible Duplicate:
Does anybody here have experience in automating some tasks in web applications using curl?
Here is what I need to do? Wondering what platform is most suited - easy to ...
2
votes
1answer
222 views
Is it a good idea to supplement shell script with perl purely for use of regex?
I'm looking for a simple way to utilize regex in a UNIX shell script where not every system will have perl extensions built into grep. What is really helpful about perl regex here is back/forward ...
4
votes
1answer
258 views
Passing clicked links in rxvt to a script
I start my browser vimprobable in tabbed like so:
"`tabbed -d > /tmp/tabbed.xid`; vimprobable2 -e `cat /tmp/tabbed.xid`" [1]
I am then able to send all new instances of vimprobable to tabbed (and ...
1
vote
0answers
802 views
Which scripting language is most widespread in system administration tasks? [closed]
I am migrating to Linux and have some experience with the Mac OS X command line/bash. I'd like to automate system admin tasks via scripting, but I am unsure as which language is the most used in the ...