I have a string like this
BRADI5G20430|BRADI5G20430.1||1
How can I replace the bar (single and multiple) with tab ("\t")?
I tried this but dont' work
sed 's/\|+/\t/g'
I also want to include this line in bash script.
...
How can I do it?
I have a file that looks like this
foo 1 scaf 3
bar 2 scaf 3.3
File2 looks like this
foo 1 scaf 4.5
foo 1 boo 2.3
bar 2 scaf 1.00
What I want to do is to fine lines that co-occur in file1 and file2
when field 1,2,3 are the same.
Is there a way to do it?
...
I have a data that looks like this:
foo foo scaffold_7 1 4845 6422 4845
bar bar scaffold_7 -1 14689 16310 16310
What I want to do is to process the above lines
where I just want to print column 1,2,3, 7 and one more column after 7th.
But with condition when printing column 7 onwards.
Below is my awk script:
awk ...
I want to have such pipe in bash
#! /usr/bin/bash
cut -f1,2 file1.txt | myperl.pl foo | sort -u
Now in myperl.pl
it has content like this
my $argv = $ARG[0] || "foo";
while (<>) {
chomp;
if ($argv eq "foo") {
# do something with $_
}
else {
# do another
}
}
But why the Perl script can't recognize the parameter passed t...
Hello,
I need to find all image files from directory (gif, png, jpg, jpeg).
find /path/to/ -name "*.jpg" > log
How to modify this string to find not only .jpg files?
Thank you.
PS: Unix
...
I have a file that is similar to this:
<many lines of stuff>
SUMMARY:
<some lines of stuff>
END OF SUMMARY
I want to extract just the stuff between SUMMARY and END OF SUMMARY. I suspect I can do this with sed but I am not sure how. I know I can modify the stuff in between with this:
sed "/SUMMARY/,/END OF SUMMARY/ s/replace/with/" ...
Hello, I am writing a program that is solving the producer/consumer problem, specifically the bounded-buffer version(i believe they mean the same thing). The producer will be generating x number of random numbers, where x is a command line parameter to my program. At the current moment, I believe my program is entering an infinite loop, ...
Hello,
I work on shared linux machines with between 4 and 24 cores. To make best use of them, I use the following code to detect the number of processors from my ruby scripts:
return `cat /proc/cpuinfo | grep processor | wc -l`.to_i
(perhaps there is a pure-ruby way of doing this?)
But sometimes a colleague is using six or eight of t...
Imaginary Situation: You’ve used mysqldump to create a backup of a mysql database. This database has columns that are blobs. That means your “text” dump files contains both strings and binary data (binary data stored as strings?)
If you cat this file to the screen
$ cat dump.mysql
you’ll often get unexpected results. The terminal ...
If i have file for eg: a log file created by any background process on unix,
how do i view the data that getting updated each and every time.
i know that i can use tail command to see the file.but let's say i have used
tail -10 file.txt it will give the last 10 lines.but if lets say at one time 10 lines got added and at the next instan...
I have a c++ source code that was written in linux/unix environment by some other author.
It gives me errors when i compile it in windows vista environment. I am using Bloodshed Dev C++ v 4.9. please help.
#include <iostream.h>
#include <map>
#include <vector>
#include <string>
#include <string.h>
#include <strstream>
#include <unistd...
I am unclear on the need and the usage of a pid-file and I wanted to know what is the correct usage of a pidfile and what are the best practices surrounding it.
...
We have a vendor application where we download their updates and deploy a war file. We are deploying the war file on a unix application server running oracle application server 9i. I believe when we deploy the war file, we remove the previous install and then deploy the new war file. When we deploy the war file, sometimes we have to m...
The mark " in Vim takes you to your last cursor position. I want to create an alias that will open my Vim instance and jump to that mark; something which is obviously extremely useful.
This works from the command line:
$ vim -c "'\"" File.cpp
Now I want to make an alias for this:
$ alias v='vim -c "'\""'
Well that's not goin...
For some reason, I'm having a hard time trying to cover the block of code below. This code is an excerpt from the UNIX uniq command. I'm trying to write test cases to cover all blocks, but can't seem to reach this block:
if (nfiles == 2)
{
// Generic error routine
}
In context:
int main (int argc, char **argv)
{
int optc = 0;...
I am aware that it is not possible to echo the * while you type in standard ANSI C. But is there a way to display nothing while someone is typing their password in the console. What I mean is like the sudo prompts in a Unix/Linux terminal. Like if you type in the command: sudo cp /etc/somefile ~/somedir. You are usually prompted for the ...
I am wondering if there is a function I could use in the standard libary. Do I need another library (BTW, I am developing for unix).
...
I have a makefile that looks like this
CXX = g++ -O2 -Wall
all: code1 code2
code1: code1.cc utilities.cc
$(CXX) $^ -o $@
code2: code2.cc utilities.cc
$(CXX) $^ -o $@
What I want to do next is to include 'clean target' so that every time
I run 'make' it will automatically delete the existing binary files of code1 and code2
bef...
I'm trying to set up Drupal 6 multisite in a shared hosting environment. The main site's location looks like http://www.mysite.com/foo/bar/ and my goal is to create another site using the same database at http://www.mysite.com/foo/bar/drupal2.
I've created a new folder in the sites directory called www.mysite.com.foo.bar.drupal2 and ad...
In Bash script, what is the difference between the following snippets?
1) Using single brackets:
if [ "$1" = VALUE ] ; then
# code
fi
2) Using double brackets:
if [[ "$1" = VALUE ]] ; then
# code
fi
...