Programming :: Set The Record Separator To An Empty String?
May 4, 2010
I tried to find out how awk works with multiline strings. I found this. I hope it will be useful for somebody. 1. I know that awk can searches simple patterns like '/^one/'
Code:
s="one
two
three"
echo $s | awk '/^one/'
2. I know that "Awk can handle multiline records by specifying the field separator to be a newline and set the record separator to an empty string." I've found it here
[Code]....
View 9 Replies
ADVERTISEMENT
May 19, 2011
The script produces 2 empty lines and I don't know why.
View 1 Replies
View Related
Mar 13, 2016
Code: Select allmyusername@mycompname:~$ varCurl="abc def curl: ( xyz asdf"
myusername@mycompname:~$ expr index '$varCurl' "curl: ("
4
myusername@mycompname:~$ expr index "$varCurl" "curl: ("
3
myusername@mycompname:~$ echo $varCurl
abc def curl: ( xyz asdf
How to make sure that space is treated as space and string is not treated as array? (I expect value of 9 or 10, not 3 or 4).
View 2 Replies
View Related
Apr 2, 2011
I want to replace a string of directory path in a string to empty:
Code:
But this doesnt seem to give me the desired thing:
Code:
This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.
View 3 Replies
View Related
Jul 5, 2011
With this I may remove the last emtpy char which is not visible, coming from net, windows, ...
Code:
echo "$mystringwindowsorotherwithemptylastchar" |sed s/.$//
However if there are not then it makes a problem and delete effectively an existing char.
Code:
echo "klklj" |sed s/.$//
klkl
Anyone would have a solution for SH?
View 2 Replies
View Related
Oct 22, 2010
copy string a to string b and change string b with toupper() and count the chars
View 3 Replies
View Related
Jul 9, 2010
I am unable to write a simple Makefile. Though I know the concept am facing this error:
Makefile:2: *** missing separator (did you mean TAB instead of 8 spaces?). Stop.
Should I give a tab or spaces not able to continue.
View 5 Replies
View Related
Apr 20, 2010
The lines beginning with greater-than symbols are the sequence descriptors and the lines immediately after each descriptor with A-Z characters, dashes, and question marks are the aligned DNA sequences. The sequences are always the same length within a file and never span/wrap across more than one line.I am trying to write a script to remove positions in the sequences that are only represented by a -, X, ?, or N (these represent gaps or missing data). Also, if there is exactly one non-gap/missing character in a position it is also useless (there is nothing to compare it to) so I would like to remove those positions as well.
Position 5 (from the left) was removed because it was all gap/missing characters. Position 9 was removed because only one character was a non-gap/missing character. Position 10 was retained because there were 2 non-gap/missing characters.I'm really not sure where to start here. My first concern is I can't figure out how to tell awk to treat each character in lines not containing a greater-than symbol as a separate field. After that, I'm thinking I should use set up a counter to count the number of lines with gap/missing characters comparing that to the total number of lines not containing greater-than signs?
View 14 Replies
View Related
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
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
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
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
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
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
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
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
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
Jun 17, 2010
I am using embedded Linux. File open is successful. The file has all the permissions. It is present in current directory too. The size is about 27KB. But s.st_size says it is zero.
inputFileName = "abc.mp3";
FILE* inFile = NULL;
inFile = fopen(inputFileName, "r+b");
[code]...
View 2 Replies
View Related
Dec 5, 2009
I'm using rmdir(), and everything goes ok if the directory is empty, ?how can I remove the entire tree when i have other files or directories in the folder that I want to delete?I've read about using "system(rm....)" but i REALLY want to do this without it, is it possible?
View 4 Replies
View Related
Apr 26, 2010
I want to check if a MySQL db query will return an empty result - I first do this:
$query="SELECT * from <whatever" ;
$result=mysql_query($query) ;
$row=mysql_fetch_row($result) ;
Now how do I check if $row is empty or not? Will $row="" do the trick?
View 2 Replies
View Related
Apr 12, 2011
Greetings EveryOne
how to check if buffer is empty in c?
View 14 Replies
View Related
Apr 5, 2010
In /etc/fstab, I have a record:LABEL=/< >/< >ext3< >default,nolog< >1 1 represent a tab between 2 fieldsI just want to remove "nolog" in the 4th field (only): gsub(/nolog/,"",$4)The function work ok but it returns a record:LABEL=/ / ext3 default 1 1I know the problem is OFS=" ", but how can I keep the format of the record? (the same number of tabs, spaces).
View 5 Replies
View Related
Mar 26, 2011
Using awk I pull the first field of a random line from my datafile.myvar1=`awk -F" " 'NR=='$randline' {printf "%s", $1}' myfileThis works fine. The problem is there will be empty lines at the end of the file. Rather than using awkto filter out blank lines I would like to figure this out first.So I test $myvar1 for a blank string after setting $randline to one that I know is blank:test -z "$myvar1" && echo "true" || echo "false"But, this returns "false"? So the string is not zero length. Why? It's a tab-separated file. Is awk storing the tab with the $1 field or something.This is where I get headache. I try to echo my variable to see what it looks like.
echo "$myvar1"
outputs: nothing
echo "My variable is [$myvar1]"
outputs: [y variable is [
Why is the closing bracket at the beginning? What character could be stored in $myvar1 that would do such a thing and how did it get there?
View 7 Replies
View Related
Nov 28, 2008
To do this, can I do this?:
if (@ary = ""),
or is something more needed?
View 4 Replies
View Related
Apr 27, 2010
Let say I would like to check /etc/profile whether defined umask 022
umaskcheck=$(What to defined here?)
if [ What to define here? ]
then
[code]....
View 2 Replies
View Related
Jan 30, 2011
Xorg is so cool. Anyhow is there some solutions to make video of the screen using only the regular tools of xorg or import or scrot even?
View 1 Replies
View Related
May 20, 2010
I was trying to list sudo users in a Linux Machine,
[root@redhat ~]# grep -v -E '^#' /etc/sudoers
root ALL=(ALL) ALL
%work ALL=(ALL) ALL
%dilipvp ALL=(ALL) ALL
where work is a group and dilipvp is user. Can you help me in creating a better script which can list the members of the group work as well. and why I am getting empty space in between.
View 6 Replies
View Related
Mar 25, 2010
i am reading a database flat file with the "awk" command which has 4 fields separated by colon ":" .I want to show the output of these fields in a certain way that every record is numbered e.g
1.some text
2.some text
Is there a way to do this?
View 14 Replies
View Related
Aug 25, 2010
i want to capture the mouse events (click,double..,position ) as well as keyboard events (key strokes) for every application running separately?
View 1 Replies
View Related
Aug 6, 2010
I would like to extract Room number, Lastname,Firstname,invoice (205880080),arrival date, departure date, and total(229.46). Can you at least give me a hint on how to proceed? I have tried a lot but I am stumped from the beginning.
***History***
Room: 124 B Payment: Bell/TRAVELSCAPE.COM
Lastname*FIT*,Firstname 4A, 0K, 0B Guest
Bell *205880080 FT
Bell *205880080 July 31, 2010
[Code]...
View 4 Replies
View Related