Hi In Reference to this question After getting the line identifier matching in first and second file I need to replace the line in first file with the line of second file.For that I am using SED as below. But Sed only replaces that line in a new file. How can I achieve the updation in same file without temporary file.(Because those are v...
I am writing a shell script and I am stuck. The requirement is: I will receive files which have a sequence number on them like xyz0001abcd.DAT. I create a copy of that file, keeping the sequence number, as abcd000001gfh.DAT. The original filename uses four digits (up to 9999), and the copied one uses six (up to 999999).
I am stuck when...
I have a command like
echo "abcd0001gfh.DAT" | sed 's/^[^0-9]*\(....\).*$/\1/' | awk '{ print "00"$0 }'
This will give me an output of 000001. But I want to run
this in a loop where I receive the file name from 0001-9999
and again it becomes 0001. So my output should like below
abcd0001gfh.DAT 000001
abcd0002gfh.DAT 000002
.
.
.
a...
I have a data that looks like this (FASTA format). Note that
in comes with block of 2 ">" header and the sequence.
>SRR018006
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGN
>SRR018006
ACCCGCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
What I want to do is to append a text (e.g. "foo" in the > header)
yielding:
>SRR018006-foo
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...
i have two files ...
file1:
002009092312291100098420090922111
010555101070002956200453T+00001190.81+00001295.920010.87P
010555101070002956200449J+00003128.85+00003693.90+00003128
010555101070002956200176H+00000281.14+00000300.32+00000281
file2:
002009092410521000098420090709111
010560458520002547500432M+00001822.88+00001592.96+00001...
Hi
In a shell script we can connect to a Database using sqlplus on unix.
can i perform the same thing inside an awk script?
i need to access the output of a select query inside an awk script.is that possible?
...
how could we compare lines in two files using a shell script.
I want to compare line in one file with the line in other.diff will give me all the differences in two files at a time.i want a line in the first file to be compared with all the lines in the second file and get the common lines as the output. with the line numbers where the ...
Wow, this one has really got me. Gonna need some tricky sed skill here I think. Here is the output value of command text I'm trying to replace:
...
fast
n : abstaining from food
The value I'd like to replace it with, is:
...
Noun
: abstaining from food
This turns out to be tricker that I thought. Because 'fast' is listed a...
I have several large files, each of which I want to chunk/split it in to
predefined number of parts.
Is there an efficient way to do it in Unix (e.g. via awk/sed/perl)?
Also each file can have varied number of lines.
File1.txt 20,300,055 lines
File2.txt 10,033,221 lines
etc...
...
How to I find and replace every occurrence of:
subdomainA.example.com
with
subdomainB.example.com
in every text file under the /home/www/ directory tree (recursive find/replace).
...
The following code is working as expected. But I can not format the output.
It will print something like this:
mysql
test
someDB
I want the output on a single line
mysql test someDB
I tried using sed in the script but it did not work.
#!/bin/sh
for dbName in `mysqlshow -uroot -pPassWord | awk '{print $2}'`
do
echo "$dbName" | egr...
Using just grep and sed, how do I replace all occurrences of:
a.example.com
with
b.example.com
within a text file under the /home/user/ directory tree recursively finding and replacing all occurrences in all files in sub-directories as well.
...
I have a directory with files that look like this:
001_something.php 002_something_else.php
004_xyz.php 005_do_good_to_others.php
I ultimately want to create a new, empty PHP file whose name starts with the next number in the series.
LIST=`exec ls $MY_DIR | sed 's/\([0-9]\+\).*/\1/g' | tr '\n' ' '`
The preceding code gives ...
File1:
<a>hello</b> <c>foo</d>
<a>world</b> <c>bar</d>
Is an example of the file this would work on. How can one remove all strings which have a <c>*</d> using sed?
...
File1:
hello
world
How would one delete the leading/trailing blank spaces within this file using sed - using one command (no intermediate files)?
I've currently got:
sed -e 's/^[ \t]*//' a > b
For leading spaces.
sed 's/ *$//' b > c
And this for trailing spaces.
...
File1:
hello (OPTION1) 123456 123456 123456
world (OPTION1) 123456 123456 123456
foo (OPTION1) 123456 123456 123456
bar (OPTION1) 123456 123456 123456
How would one remove each string after each first word in the textfile File1?
This would probably be down with awk/sed/cat - but I cannot figure it...
I have a table with two columns
column_1 column_1
12345 12345
73255 73255
71377 71377
Now i want to create an xml like
<header>
<value>12345</value>
<value>73255</value>
<value>71377</value>
<footer>
basically i need to use a select query and put any one of the fields into the values of xml.
could you please suggest h...
Basically, I am creating an XML file by taking the values from a column of a table.
I am starting an AWK script from a shell script (ksh if it matters) like this:
SQL_RESULT=`sqlplus -s ${CONNECT_STRING} << EOF
${SQLPLUS_SETTINGS}
select customer_id from GD9_GENTH_CUST_SUBSCR;
exit;
EOF`
FILE_LIST=`echo $SQL_RESULT|sed -e 's/\n/''/g'`
...
I'd like to use Sed to expand variables inside a file.
Suppose I exported a variable VARIABLE=something, and have a "test" file with the following:
I'd like to expand this: "${VARIABLE}"
I've been trying commands like the following, but to no avail:
cat test | sed -e "s/\(\${[A-Z]*}\)/`eval "echo '\1'"`/" > outputfile
The result i...
I have some data on a single line like below
abc edf xyz rfg yeg udh
I want to present the data as below
abc
xyz
yeg
edf
rfg
udh
so that alternate fields are printed with newline separated.
Are there any one liners for this?
...