Debian :: Expr Index - Treat Space As String Not Array Separator
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
ADVERTISEMENT
Oct 5, 2015
I have up until now been able to use the add-apt-repository command without issue but right now it keeps returning an IndexError.
The error is below:
Code:
Select allx@y:~$ sudo add-apt-repository ppa:/kilian/f.lux
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 122, in <module>
shortcut = shortcut_handler(line)
[Code] ....
IndexError: string index out of range
I have tried using the command with an empty ppa (just sudo add-apt-repository ppa:) but that comes with the same error. Googling the issue only brought up some bugreports of a month back, and I've used the command with success a few days ago.
View 4 Replies
View Related
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
View Related
May 3, 2010
I am having a little trouble with a Bash shell script that I am working on. It is intended to read the information out of a gedcom genealogy file and determine who has lived in a particular area and output a report based upon who lived in a given area (like the different sections of a bygdebok for example). I am having a number of issues.
1) I can't seem to figure out how to get a variable to work as the index of an array. For example, I am trying to use the variable $individual to count which individual is being read in from the .ged file, and once that is figured out, next I will read in the individual's name, so I would like to create an array of names using the variable
Code:
$individual
as the index of the array. However, if I try the code
Code:
name[$individual]=$lineoftext;
[Code]....
I included only the last few lines of output as to not take up too much space because the output goes on forever, but you get the point from the example. This output has nothing to do with what the final output of the program is intended to be like. It is merely a test to prove that the 2 variables in question are getting their date loaded in properly.
View 14 Replies
View Related
Apr 19, 2011
When I start Gnome-Schedule, it opens and closed right away. Here's the output:
[Code]....
IndexError: string index out of range Also before this happened, I tried to add this command to G.S. but nothing happened when I clicked "Add":
[Code]...
View 1 Replies
View Related
Nov 9, 2010
My system is giving me a low space on filesystem warning. When I run disk analyser, it seems that /var/lib/apt-xapian-index is using 97% of it!! That's 8.9GB. I found another post which explained that each time this package runs it builds a new index set, and how to make it only update new packages. I made that change, but this doesn't release the 8.9GB that I guess can just be cleared down somehow...
I hope it can be cleared down anyway. How to clear all this down? I do want the package to remain running on the system, I just want to clean it up and release all that space. I'm on Lucid, I also saw the warning on Jaunty but it went away after upgrade to Lucid... now it's happening again, I can't ignore and hope it goes away for ever!
View 3 Replies
View Related
Oct 29, 2009
I've got a problem...
a[0] = 22
echo $[a[0]]
echoes 22 - that works fine
[code]...
View 5 Replies
View Related
May 9, 2010
I've searched around and can't find out how to convert a string ( like "12345" ) into an int array ( x[ 5 ] = { 1, 2, 3, 4, 5 } ; ).
View 4 Replies
View Related
Mar 7, 2011
Can you create a dynamic string array and using calloc(),realloc()?
Like:
Code:
string* x;
x = (string) calloc(x,sizeof(string));
View 9 Replies
View Related
Oct 14, 2010
I am using gnu bash 3.2I need to split the string into array like
a=this_is_whole_world.file # split [_.]
I need to split this on _ and . some thing like this
a[0]=this
a[1]=is
a[2]=whole
a[3]=world
a[4]=file
preferable using bash regex. if not sed is also ok.
View 2 Replies
View Related
Mar 17, 2011
how do I split a string into an array?In this string:"this is a story"how do I split it by the space?
View 8 Replies
View Related
Jan 12, 2009
I need to call a function that takes a string array as argument, declared like this:Code:int someFunction(/* some parameters... */, const char* s[]);I'd like to know how to allocate memory for the string array. I know a string is an array of chars and an array is a pointer to the first element, then a string array should simply be a two dimensional char array. But is it a single memory block where all strings are stored consecutively?? Or is it a base vector where each element is a pointer to a separate memory block that contains a single string?More specifically: should I malloc() a single memory block large enough for all the strings? or should I allocate separate blocks for each string plus an extra one for the base vector?
View 5 Replies
View Related
Aug 18, 2010
i have problem in java. how to convert string array to character. e.g string a[]={"ab","abc","abd","ag"}; what will be the character array ?
View 3 Replies
View Related
Jan 24, 2011
How can I list string indexes from an array in ksh ?
View 4 Replies
View Related
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
May 13, 2009
Please look at the comments
Code:
/*
* TEST CASE TO CHECK DIFFERENCES BETWEEN STRING AS
[code]...
View 14 Replies
View Related
Oct 11, 2010
I want to put a string, such as the one found in the image, into an array that will later be chopped into individual words and put into another array of individual words found in the initial string. (or, perhaps, I would be able to do that initially, but for now, that is the goal)My question is, how can I do that without using quotation marks?
View 5 Replies
View Related
Jun 4, 2010
How can i split a string like this,
Code:
This is my first line.
This is my second line.
This is my third line.
into,
Code:
"This is my first line.", "This is my second line.", "This is my third line."
in C++.
i.e. split the code at every new line
View 11 Replies
View Related
Apr 8, 2011
I have a sed match that matches for certain string of a regex expression:
Code:
tname=$(echo "$contents" | sed -n 'some pattern')
How do I match for multiple strings in the $contents and return them as an array? for example
Code:
contents="this is a text, just to match patterns, here is another text to be matched"
the sed func would be able to recognize both "text"s, but only one is outputted?
Possible to put it in an array? so ${bar[0]} gives one and ${bar[1]} gives another
View 3 Replies
View Related
Oct 13, 2010
This may be a basic bash array/string operation related question, but I couldn't find any direct answer. So here it goes:I have a lot of data sorted in various directories. All directories need same processing except for a special group of directories. I have a symbolic link of the script in discussion in each directory. I want the script to get the name of the current directory, check if that belongs to special group and do specific operations.So I get the name of the directory
Code:
mm=`basename `pwd``
Now the the group of directories that needs something different to be done, contains these
[code]...
View 4 Replies
View Related
Mar 21, 2011
I'm trying to split a string, to later iterate using a for loop like
Code:
for (( i=0; i<5; i++))
But, my script returns an array with the size 1.
Here's the script:
Code:
aver=$(grep "avg" A.txt | awk '{ print $2 }');
a=$(echo $aver | tr " " "
");
[Code]....
View 2 Replies
View Related
Mar 29, 2011
Here is the issue. I am reading in a outside text file and putting in the string on that line into a char array that is already allocated.
Code:
int main(int argc, char *argv[])
{
[code]....
View 1 Replies
View Related
Feb 16, 2010
Just check out the script...
Code:
1 #!/bin/bash
2
[code]....
View 2 Replies
View Related
Feb 4, 2010
How to let awk consider a string by double quota as one field? for example:
echo "first "second is a string"" | awk '{ print $2 }'
I want to print out "second is a string".
View 8 Replies
View Related
Feb 9, 2010
I am using Sun 5.9.
I am putting the value "Feb 10" in variable 'c' here.
Code:
-bash-3.00$ c=`date | awk '{print $2 " " $3}'`
-bash-3.00$ echo $c
Feb 10
But when I am grep-ing value of 'c', I am getting this error.
Code:
-bash-3.00$ ls -lrth | grep $c
grep: can't open 10
This is because there is a space between "Feb" and "10".
View 5 Replies
View Related
Jul 26, 2011
I have a tsv file that I'm trying to break down, line by line, then column by column so to speak. The file is a list of exported usernames, passwords, and display names from an email server, I need each separate to be used in other commands to provision the new server. My problem is, each display name contains a space, as usual with people's names. Here is the script for reference:
Code:
while read line
do
uname=`echo $line | awk '{ print $1 }' >> works`
pass=`echo $line | awk '{ print $2 }' >> works`
[code]....
View 14 Replies
View Related
Sep 12, 2009
Ok, as the title indicates I have a RAID5 array with 4 500GB SATA drives. This is the only drive configuration on the system (i.e. the OS also resides in the RAID array). I'm running CentOS 5 and need to know how to go about increacing the space in the RAID array by replacing the drives with 4 1TB drives.
View 3 Replies
View Related
Aug 19, 2010
Is there any inbuilt function other than strncmp which can evaluate a string.my requirement is " if all 10 values are spaces print 1 else if it contains some values print 2 else print 3.if i use strlen, even space is counted.I know that i can evaluate using for loop by checking 1 by 1 char, and using strcmp function, is there any other way?
View 2 Replies
View Related
Sep 30, 2010
I have a PC with Windows 2000 Pro installed in an NTFS partition of 60GB. My rest hard disk (500GB) is empty, no partition at all. When I run Ubuntu 10.04 installation after step number 3 I get a weird step number 4 showing prepare partitions with an empty array and no available command button at the bottom! So I can not create any partition... Also in step 4 I never see the "prepare disk space" menu. If I use a 9.04 Ubuntu CD and I try to install I get every menu fine as expected. I even tried the 10.04 CD to another PC with Windows XP PRO and the installer worked as expected for partitions.
View 1 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