10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
I have a text file with many thousands of lines, a small sample of which looks like this:
InputFile:PS002,003 D -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 6 -1 -1 -1 -1 0 509 0
PS002,003 PSQ 0 1 7 18 1 0 -1 1 1 3 -1 -1 ... (5 Replies)
Discussion started by: jvoot
5 Replies
2. Shell Programming and Scripting
I have a file that I am trying to find a specific word, then replace text within that string.
file
TestA2015
TestB2016
Example. Replace TestB2016 to TestB0000, so if TestB is found replace the original "2016" to "0000". Thank you :).
awk tried
awk '{ sub(/TestB$/, "0000", $6) }1'... (5 Replies)
Discussion started by: cmccabe
5 Replies
3. Shell Programming and Scripting
Hello experts!
I have 2 files.
file1 is a list file containing uniquely names. e.g.:
name1 number number
name2 number number
name5 number number
name10 number number
...
file2 is a data file arbitrary containing the names of file1 in paragraphs separated by "10" e.g.
name4 ... (3 Replies)
Discussion started by: phaethon
3 Replies
4. Shell Programming and Scripting
Hello, I have the following input file:
1 3 3 2
3 3 4 0
4 0 5 4
5 2 2 0
5 3 4 0
6 0 3 2
I am trying to remove all zeroes in fields 2 and 4 and replace them with "1's"
I tried the following, but it's not working
awk -F"\t" '{ if (($2==0) || ($4==0) $2=1; $4=1; print $0 ) }' input
... (8 Replies)
Discussion started by: Rabu
8 Replies
5. Shell Programming and Scripting
Friends,
I have more the thousand lines like this.
check.cloud1.port=342
check.cloud2.port=5456
check.cloud3.port-4564
But we need to transfer it to
_CHECK.CLOUD1.PORT_=342
_CHECK.CLOUD2.PORT_=5456
_CHECK.CLOUD3.PORT_=4564
Any one could pls help of this. Thanks in Advance
... (1 Reply)
Discussion started by: jothi basu
1 Replies
6. Shell Programming and Scripting
Hi,
Say I have a record "1|22| | |". In which the third and fourth fields are <space> alone. I have to replace the <Space> with <null>.
Input:
"1|22| | |" --> "1|22|<space> |<space> |"
Expected output:
"1|22|||" --> "1|22|<null> |<null>|"
I tried:
echo "1|22| | |" | awk -F... (4 Replies)
Discussion started by: machomaddy
4 Replies
7. Shell Programming and Scripting
Need some code tweak:
awk 'END {
for (i=1; i<=n; i++)
if (f2])
print f2]
}
NR == FNR {
f2 = $1] = $0
next
}
$1 in f2 {
delete f2
}1' FS=, OFS=, 2.csv 1.csv > 3.csvfile 1.csv have:
$1,$2,$3,$4,$5,$6,$7,$8,$9......
file 2.csv have:
$1,$2,$3,$4,$5,$6 (2 Replies)
Discussion started by: u10
2 Replies
8. Shell Programming and Scripting
Hi suppose I have a csv file like this
count,1977,1978,1979
usa, , , blue
japan, red, yellow,green
india, , yellow,blue
china, blue, yellow, green
I want the output to be(replace everything, including empty data, with the most recent data):
... (1 Reply)
Discussion started by: grossgermany
1 Replies
9. Shell Programming and Scripting
Greetings all.
I have web site that has long option and switch lists. When I insert something new into these files, the lists need to be reordered. IE:
1 => apple
2 => pear
3 => bannana
4 => orange
---------------------
Add grape as #2
1 => apple
2 => grape
3 => pear
4 =>... (2 Replies)
Discussion started by: RobertSubnet
2 Replies
10. UNIX for Dummies Questions & Answers
hello.
I'm somewhat a novice here so please be patient. My stumbling block when loading csvs into ORACLE tables is this:
I need to read a csv datafile, check several fields in each line, and if any of stated fields contain A ZERO only then replace it with a null/blank character.
I had a... (9 Replies)
Discussion started by: MrCarter
9 Replies