Programming :: Append To String In Awk?

Sep 20, 2009

I'm having problems completing my school exercises with awk.

Heres the desired outcome:

Code:

./my_awk 2
ACG GAG ATT AGG AGG ATC CCA CCA
CAC AGG ACG GAG ATT AGG AGG ATC

So it generates data in group of threes, 8 groups per row and prints it. My problem is that I can't seem to get awk to append stuff to string so I could print it nicely to screen. It just prints empty lines per the parameter given to it.

Heres my code so far:

Code:

#!/bin/sh
awk -v rows=$1 '
BEGIN {

[code]....

View 2 Replies


ADVERTISEMENT

Programming :: How To Append A String To A Next Line In Perl

Apr 9, 2010

I have a requirement like this..this just a sample script...

Code:

when i run this scipt...

Code:

Code:

It is appended in the same line...

I want it to be added to the next line.....

I want to do this by explitly using the filehandles in perl....and not with redirection operators in shell.

View 1 Replies View Related

Programming :: Using Bash To Append A String To Array?

May 19, 2011

I have the following function that does not iterate through the array I want to be able to do some manipulation on each element in the array[@].it appears the below array has only one item in the array whereas i want the array to have 3 items hence the loop three times printing the message Any ideas why this is not happening ?

function foo() {
name =$1
array=( "$2" )

[code]...

View 5 Replies View Related

Programming :: Append Variable String In A Specific Line?

Jun 8, 2010

I want to append a variable string to the end of a specific line. not like append the same string to each line. like in my file i have 4 columns, i want to add a string in 5th column in some fixed row.

View 4 Replies View Related

Programming :: List All The Files That Don't Contain Pattern1 And Append A New String?

Mar 24, 2011

How to list all the files that don't contain pattern1 and append a new line (pattern1) to those files before pattern2 only once.

pattern1 = /var/script/showMessage.sh
pattern2 = ;;

Code:
grep -c 'pattern1' /var/script/*_cam* | grep :0 | add pattern1 before pattern2 in each file loacted before.

View 10 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

Programming :: Pthread - Take String From The Command Line And Creates A Thread To Print The String

May 3, 2011

I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.

[Code]....

One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?

Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.

View 6 Replies View Related

Programming :: Using Sed Replace Line Containing Particular String By A Single String?

Oct 16, 2010

I have a set of lines as ahown below:

Leon went to school
Leon came back from school..
Leon had dinner...

I have to replace the line containing "dinner" by a single string LUNCH...

View 2 Replies View Related

Programming :: Creates String Suffixes Out Of A Reference String?

Feb 25, 2011

I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be

1)bcdefg
2)cdefg
3)defg
and so on...

create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?

View 9 Replies View Related

Programming :: C - Put A Specific Arbitrary Part Of A String Into It's Own String?

Apr 18, 2010

So if I'm given a location of a file like:

How can I just take the type of the file at the end? I know I can use strrchr() for a period to get the pointer to the period just before file type. Is there a build in string function that will just take the rest of the string from a certain point on forward in the string? I know it wouldn't be much work to make it myself, but I figured I would find out if it already existed before doing it.

View 9 Replies View Related

Programming :: Convert String To Integer Back To String C++ ?

Mar 13, 2010

Code:

The error is:

Code:

What I want to do is take input of ip4 as a string, convert it to an integer to add 1 to it, then reconvert it back to a string. Its not working.

My full code is:

Code:

View 1 Replies View Related

Programming :: Assigning Custom String To Std::string In C++?

Oct 12, 2009

I've been given a custom-made string class which handles string, wstring and bstr. It has a number of methods and assignment operators to convert to and from different types. The app I work on compiles happily in VS6 and VS2008, but when trying to compile in Redhat (version 4.1.1 in Redhat 5.0)

[code]....

View 4 Replies View Related

Programming :: How To Check If All Letters Of One String Are In Another String?

Nov 11, 2010

I have the following two type of strings1: A/D2: A/C/DI am trying to write a subroutine to check whether all of the letters in string 1 appears in string 2. If yes, return true. If not, return false. In the above example, all the letters (A and D) in string 1 are also present in string 2, so I return true.

View 4 Replies View Related

Programming :: Append A / At The End Of The Line?

Aug 10, 2010

The s means substitute
The $ in this particular regex (regular expression) means end of the line.
The ; is what you're subbing. This works fine and well, but what if you want to append a / at the end of the line?

sed 's/$///' filename doesn't work.

View 1 Replies View Related

Programming :: Sed Append To End Of A Specific Line?

Jan 29, 2011

What I am trying to achive is the editing of /etc/ssh/sshd_config I have the line

Code: AllowUsers usera userb

And I want to be able to append to the end of this line from a bash script.I have muddled together from other sites and got the following:-

Code: sed -e "s/^AllowUsers/� userc/" -i /etc/ssh/sshd_config

But this appears to add userc directly after AllowUsers and not after userb

View 2 Replies View Related

Programming :: Append Item To A List ( C Macro )?

Apr 13, 2010

I have my own declared types and I have to operate with lists of items. I wish to write a one macro, instead of using a function for each type. It's intended to be like this: Code: #define ____append_to_list(head,

item, type)
type* ptr;
for ( ptr = head; ptr->next != NULL; ptr = ptr->next )

[code].....

View 9 Replies View Related

Programming :: Bash: Remote SSH Command Append To AWK?

Sep 29, 2010

I have the following command that works Code: ssh root{at}IPADDRESS 'vim-cmd vmsvc/power.getstate 64 | grep Powered | awk "{ print $2}"' Which outputs the following text:- Powered on I would like to Append some text so the output is:- Ubuntu Server: Powered on Every different variation that I have tried ends up in an unexpected token.

View 1 Replies View Related

Programming :: Append Numbers To A Word List?

Dec 30, 2010

If I do:

for i in $(cat names); do seq -f "$i%03.0f" 0 999; done > output5.txt

I got ( tail snipped):

997munt
998munt
999munt

If I do:

for i in $(cat names); do seq -f "%03.0f$i" 0 999; done > output4.txt

I got:

997Zygmunt
998Zygmunt
999Zygmunt

How I can get numbers from 000 to 999 appended like:

Zygmunt997
Zygmunt998
Zygmunt999

View 8 Replies View Related

Programming :: How To Append Text To Second Line Of File?

Nov 6, 2010

Say I have a text file like:
Code:
1
3
4
How would I use ksh to put the number '2' into the second line of that file?Okay it's not bash, it's ksh because this computer is OpenBSD

View 14 Replies View Related

Programming :: Append Text To The Beginning Of A File?

Jan 14, 2010

I am trying to append text to the beginning of a file. This is what I have so far.

Code:
date_default_timezone_set('America/Chicago');
$date=date("m-d-Y g:i:s a");

[code]....

View 7 Replies View Related

Programming :: Unable To Append To A File Through Perl/CGI

Apr 6, 2010

where I'm trying to demonstrate the file locking concept through Perl/CGI.Here is the script which I tried.

Code:
#!/usr/bin/perl -w
use strict;
use warnings;
print "Content-type: text/html

[Code].....

View 2 Replies View Related

Programming :: [Java] Append Something To Each Line In A Text File?

Apr 15, 2009

I am thinking of appending something to each line in a text file with Java. I prefer not write a new file with content appended from the old one.That 'something' would probably be Time Stamp when the file is created (which is same for each line).I am not sure Java provide some easy way for it or not

View 3 Replies View Related

Programming :: Append A Block Of Text Into A Particular Section Of A File?

Mar 16, 2010

So I have file which looks something like this:

cat .opera/operaprefs.ini
Code:
[User Prefs]
Language Files Directory=

[code]...

View 1 Replies View Related

Programming :: Convert The Int To A String Using Stringstream Then Convert The String To A Char?

Mar 26, 2011

Do I have the convert the int to a string using stringstream then convert the string to a char? or is there a more direct way?Also is there a way to tell the length of a int?

View 5 Replies View Related

Programming :: Serial Port Programming String?

Nov 24, 2010

I have a serial port program which is reading a string .if(read(readfd,sResult,1)>0)where sResult is unsigned char sResult[10];if sResult is array of 10 then iam getting string perfectly but if iam making sResult only as unsigned char I am getting NULL value CODE BELOW

Code:
unsigned char sResult;
main()
{
readfd = open("/dev/ttyUSB0", O_RDONLY);
if (readfd == -1)
{
perror("READ: open_port: Unable to open /dev/ttyUSB0-

[Code]...

View 2 Replies View Related

Programming :: Append Contents Of One File To Another Existing File?

Nov 17, 2008

I have two files list1.cfg and list2.cfg both files contains differentrecords details like

List1.cfg
NAME1:25:C:NAME LINE1:
NAME2:25:C:NAME LINE2:
CITY:25:C:City:

[code]....

Now I want to append contents list2.cfg to list1.cfg(It ispposible using cat list2.cfg >>list1.cfg) but I want to check if content of (record) in list2.cfg is present in list1.cfg then dont append it otherwise append it.

View 1 Replies View Related

Programming :: Getting Substring Of The String?

Sep 13, 2010

I want normal substring of a string that actually is a url as follows

SITEURL/main.php?page=122&type=download_file&fileID=9&user Id=user1&org=org1&mainmenu=main1&submenu=sub1

What I want is a substring like below

org1_user1_main1_sub1

View 5 Replies View Related

Programming :: Which Effect Does $ Before String Have?

Dec 8, 2010

Which effect does the $ before the string have? This $ before a double-quoted string is used in many initscripts on Fedora 13, but not on Ubuntu 8.04.

View 2 Replies View Related

Programming :: Convert String To Int ?

Jul 6, 2010

Iam trying to check a value less than or equals 0.The value iam getting is after doing grep a file . but its throwing error .

Code:

When i execute this it throws

Code:

View 8 Replies View Related

Programming :: Extract Value From String?

Dec 27, 2008

I need to extract a price from a string, this may vary in the future so it may be 12.99 or 14.99. i thought a sed command might crack it and i need to write to a file:<td><b class="priceLarge">?6.99</b>I need to extract the price 6.99(with no ?)so extract anyhting between "> and </B> and write it to a file such as tmp1.txt .

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved