General :: Copying Directory List Into Array Then Accessing It

Jul 22, 2010

What I'm trying to do: write a script that will list all the directories in a given location. Ask the user to enter a number corresponding to the location of the directory in the list, and then moving into that directory.

I have written a script to do this, but it only works when I run it as: <user>$program_name and the script runs in a sub-shell. But, when it is run in a sub-shell, the changes made by the script go away after the script ends.

When I run it as:
<user>$. program_name
and the script runs in the current source shell, I get an error:
bash: cd: /home/dev/Project/dirname: No such file of directory

Code:
IFS='
' read -d '' -a ArrName < <(ls ~/Projects)
read filenumber
cd $HOME/Projects/${ArrName[$filenumber]}

View 6 Replies


ADVERTISEMENT

General :: List And Kill Processes Accessing Internet In Linux?

Jul 28, 2011

How to kill the processes accessing Internet in background using terminal commands.Command to stop (disconnect) the processes accessing Internet.Command to kill the process accessing Internet.

View 1 Replies View Related

Ubuntu :: 11.04 Hangs When Accessing / Copying Files?

Jul 14, 2011

I am running an old p4 system with the latest ubuntu. It has been working wonderfully until today. It all of the sudden starts to hang when copying or even just accessing files from one specific hard drive. I have read that this is an error with ext4. Is there anyway to fix this?

It would be extremely difficult for me to transfer all of these files over if i don't know whether or not it will hang.

View 2 Replies View Related

General :: Copying Large Number Of Files From One Directory To Another

Feb 10, 2010

I've a directory containing around 2.8 lacs of files. I want to move them to another directory.If I use cp or mv then I get an error 'argument list too long'. If I write a script like

for file in ls *; do
cp {source} to {destination}
done

then because of ls command , its performance degrades.How can I do this?

View 7 Replies View Related

General :: Copying /home Directory To External Usb Drive?

Dec 21, 2010

im thinking of copying my /home directory by just click & dragging it to my external usb hard drive. then do a fresh reinstall. then just replace the new /home directory with the one on my hard drive(old home directory) will it have my original programs i used to have and all my settings & stuff?

View 10 Replies View Related

Programming :: Copying An Array Of Structs To New Variable?

Jun 27, 2011

I had a question about threads and mutexes recently answered and a members' answer sparked a different problem.'Nominal Animal' in the post mentioned said I should hold a mutex only long enough to copy my data to a temporary variable and then output by reading that temp. Here's some code on this. I must be copying the array of structs wrong because when the gui thread reads the temp copy, I end up with lots of garbage. Even running through gdb verifies that different data is in the temp array-copy than in the original.How do I go about copying this array of structs to another variable correctly in the gui thread?

Code:
typedef struct
{

[code]....

View 7 Replies View Related

Programming :: PHP Accessing Variables Within Array

Mar 30, 2011

I am pretty new to PHP so excuse my dumbness. I've searched this up in quite a few places and cant find anything : Basically, I've made an array, within it are 3 more arrays. Their are two values in each array, 'Name' and 'Age'. Basically I am using a While statement to try and cycle through the 'age' value of my array and state whether or not the person is eligible. (I am actually just learning so I'm doing this to just test myself).

Here is my code
Code:
<?php
$people =array(
array('name' => 'Bob', 'age' => 15 ),
array('name' => 'Jhon' , 'age' => 10),
array('name' => 'Sue' , 'age' => 7));
//($value =& $people[0,1,2][age] );

Here was an attempt to try and create a reference to age, I tried it many different ways
while($age < 10) {
echo ('$name, is eligible') ; } ?>

Okay, so I tried to do this through two ways, one way I tried to create a reference to age, then evaluate it, without that line of code their would be no reference, which way is correct, why wont it work? I am using Xammp, so when I launch local host I get an undefined variable error. What To Do?

View 3 Replies View Related

General :: Resuming File Copying After Remounting CIFS Directory

Mar 13, 2011

I'm trying to resume copying from a mounted CIFS device to my local hdd with cURL. I tried

Code:
$ curl -C - -O file://myfile
and also

Code:
$ curl -C <manual offset> -O file://myfile
(looked up the manual offset using "$ wc -c")

This resumes copying if I cancel it eg with ^C.

But it does not work if I unmount and remount the CIFS device. cURL then ignores my given offset and continues again from start as if nothing were there without saying a word. With "-C -" the same effect.

View 2 Replies View Related

General :: Copying Jpegs Recursively While Preserving The Directory Structure?

Aug 9, 2010

So I have a bunch of directories:

dir1
dir2
dir3
etc.

which themselves all contain subdirectories:

dir1subdir1subdir2etc.and at the lowest level they contain all of these jpegs that I need. The problem is that I only need some of them. They're named like this:

pic1.jpg
pic1_med.jpg
pic1_small.jpg
pic2.jpg
pic2_med.jpg
etc.

I want to just grab the ones without the size suffix and copy them all to another set of folders, while preserving the directory structure. The numbering all starts at 1 for each low level subdirectory, so I think that the directory structure is the only way to not get them mixed up.

I know that cp has a recursive option -r but how do I just extract the ones without the underscore? And then how do I preserve the directory structure when I move them over?

View 1 Replies View Related

General :: Accessing A Guest OS's Directory From The Host OS In VirtualBox?

Jun 5, 2010

With VirtualBox you can share a directory on the host machine with the guest machine. Can you share a directory on the guest machine with the host machine? In my setup the host is Windows 7 and the guest is Ubuntu. Can I have a directory on the Ubuntu file system accesible from Windows?

View 1 Replies View Related

General :: Inability To Accessing Shared Directory Through An Unreadable One?

Apr 15, 2010

I want to share my /home/myname/Public/ directory with other users on my system. The problem I am having is that it seems impossible to do so. I can't use a hard link because it's a directory and I can't use a soft link because the target directory can't be found by anyone unable to read my home directory.

So far, the only solutions I can see are:

1) To move everything from my Public directory to one lower on the directory tree (something like /home/Public) and then symlink to that as /home/myname/Public and allow everyone else to do the same.

2) To use something like samba to share the folder, even if only locally.

is doable because /home and /home/myname are on the same volume but there are times on my system when that is not true (I have users with their home directories on thumbdrives and external HDDs for instance and keeping their public files on a separate volume really isn't an option).

View 2 Replies View Related

General :: Copy A File And Rename It At The Same Time While Copying It To The Same Exact Directory?

Jun 26, 2010

Create a copy of the file above and call it commands.sorted. Use the vi command to manually sort this file. I.e. use yy to copy a line, P or p to paste a line, and dd delete a line. Order the commands with the two lines starting with double quotes first. Then list the rest of the command in alphabetical order.

Anyone have any ideas what he's talking about? Can I copy a file and rename it at the same time while copying it to the same exact directory again? Now sure what the two lines things means either. I have an email out to him but it usually takes a long time for him to answer me. I got alot of work to do so everytime I get hung up it kills me.

View 2 Replies View Related

Server :: Difference After Copying Large Directory To A New Directory?

Apr 4, 2010

I m having a RHEL-5 sever.ABC directory size is 57GB after taking backup in the same disk with name ABC.bkp showing 56GB. i used below command to copy/backup. # cp -r ABC ABC.bkp (different sizes after copying)..I checked both the directory sizes by #du -sh <ABC> and du -ks <ABC.bkp>In both GB and KB there is lots of difference (200mb). why this will happen in copying? what is the solution for above question? what is the correct way of copying 1dir to newdir exactly?

View 4 Replies View Related

Ubuntu Servers :: Accessing Storage Array Drives From LiveCD?

Jun 22, 2011

I'm trying to delete directories (long story, Mac temp files there, Windows not cooperating) on a sever connected to a HP 20 Modular Smart Array set up as RAID5. System currently running Windows. I've booted from a 9.10 LiveCD but can't see the external drives. Is it correct that I need to install mdadm to "see" those drives from LiveCD? From a different machine (linux) I can mount the drive using samba like so:

sudo smbmount //IP address/hostname RAID5 Root Share /mnt/ntserver -o username=smith,password=abcde123

I have admin privileges on the Windows OS. In linux (or Windows beforehand), is it possible to take ownership of the directories so that I can do a rm -f -r <dir> ?

View 6 Replies View Related

Programming :: Copy Files After Search In Array From This Directory To Another Directory?

Jan 3, 2009

After i try to find logfiles follow date/month/year. i want copy this files to another directory with name's directory is time you find(date/month/year).

View 4 Replies View Related

General :: Accessing Web Pages Shared In /Directory /home/vinay/public_html - Allowdirectory

Jun 2, 2010

I have shared few webpages in /home/vinay/public_html directory and I have made necessary changes in /etc/httpd/conf/httpd.conf file

Code:

But how to access these pages through Browser. When I open the browser with

Code:[url]

It shows contents of index.html in /var/www/html which is default DocumentRoot

How to provide the URL to access webpages in /home/vinay/public_html directory.

View 1 Replies View Related

General :: List The Contents Of Directory?

Mar 12, 2010

1 List the contents of directory, /dev using a detail listing format and page by page.

2Mount the CDROM to the directory, /media/cdrom.

3 Delete the file "/home/student/myfile" without any confirmation (Assume you have the required file permission to delete this file).

View 1 Replies View Related

Server :: Get List Of Client If Accessing?

May 21, 2011

1>i want to know how i can get list of all my client ip address whois accessing my server.either from LAN or WAN. 2>Also if some one changing my pc ip addressing for a while to use internet then how i get to know this that which pc has used my ip....

View 4 Replies View Related

General :: I /O Error When Trying To List Files In Directory

Dec 28, 2010

When I try to list files in directory. I am getting i/o error
#ls -l /test
I am getting i/o error. Why I am getting this error and what are these i/o errors.

View 5 Replies View Related

General :: Copy Folder Hierarchy / Recreate All Folders From One Directory Without Copying Over Contents Of Folder?

Jul 2, 2010

Is there a way to recreate all the folders from one directory to another without copying over the contents of the folder? I've been trying to do something like this,

Code:for i in `ls $X`; do mkdir $PATH/$i; doneUnfortunately $i is deliminated by whitespaces in the filenames and not the actual folders.

$X contains only other folders so I dont have to worry about regular files but any kind of more "advanced" solution would work.

View 1 Replies View Related

Programming :: List String Indexes From An Array In Ksh?

Jan 24, 2011

How can I list string indexes from an array in ksh ?

View 4 Replies View Related

General :: Scripting - Move A List From A Text File To Directory ?

Jan 10, 2011

I'm sure I've done this before and am having a brain fart.

I have run into this a couple of time this last month:

I have a list of torrent files (blahblahhexblah.torrent) saved in a text file. I would like to read the text file and populate the client directory.

I can echo the file using:

But I cannot remember how to pipe the output into the directory, nor can I find any resources that describe the process.

Interestingly enough, I've had a couple of opportunities to do similar tasks with passwords and privileges and even across the LAN in the last few days. Solving this problem will help me solve the others for next time.

View 2 Replies View Related

General :: Write A Bash Script That Gets The List Of Files In A Directory?

Apr 5, 2010

I'm trying to write a bash script that gets the list of files in a directory and puts them into a variable, then checks each entry and outputs them as follows:

item1 is a FILE
item2 is a DIR
item3 is a DIR
etc etc.

I am able to get the list of files into a variable, but unsure how to get the output I want.

View 3 Replies View Related

Software :: List Files/directory Names Without Directory Contents?

May 3, 2011

When I run "ls -al somedir*" (I use the "ll" shortcut, actually), Linux not only list files that match, but also the contents of directories whose name also happens to match.Is there a way to limit "ls" so that it will only show names (files and directories) and ignore the contents of the directories?

View 2 Replies View Related

Programming :: Create An Array That Will Allow To Print A List After Selection?

Oct 18, 2010

I am trying to create an array that will allow me to print a list after selection such as:

1) Location A
2) Location B
3) Location C

Would you like to print selected locations? Print I have no idea how to approach this problem and don't know whether Perl, Bash or shell script would be the most useful in this particular situation.

View 5 Replies View Related

Programming :: Split String Into An Array/list Of Lines In C++?

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

Ubuntu :: Copying Files To A Directory And Skip The Files That Already Exist In The Directory?

Jun 30, 2011

How would i go about copying files to a directory, yet skip the files that already exist in the directory, and also remove the files that are in the directory. For example:

Code:

$ls /dir1
img001.jpg
img002.jpg

[code]....

Now i would like to copy from dir1 to dir2, but the contents of dir2 would be:

Code:

$ls /dir2
img003.jpg

View 7 Replies View Related

Programming :: Copying A Directory In Ant Buildfile?

Sep 13, 2010

I'm having trouble copying a directory from one place to another in my build.xml file. I need to copy an image directory from the base directory (or root directory) to the dist directory so that it can be included in the jar file when I'm done compiling my java files.

This is my base directory:

drwx------ 1 enrique enrique 4096 2010-09-13 21:19 build/
-rwxrwxrwx 1 enrique enrique 1861 2010-09-13 22:17 build.xml*
drwx------ 1 enrique enrique 264 2010-09-13 21:19 dist/
drwx------ 1 enrique enrique 8192 2010-09-11 19:30 img/
drwx------ 1 enrique enrique 4096 2010-09-13 21:18 src/

The build/ and dist/ directories are created when I compile my java files from the src/ directory and img/ is where i have all my .png files which are needed for the program to display correctly.

Now for my Ant file: build.xml:

<?xml version="1.0"?>
<project name="PokerFiles4" default="compile" basedir=".">
<!-- Setting properties -->
<property name="dir.src" value="src"/>

[code]....

how I can get my img/ directory in the jar file would be appreciated, I'm writing a poker application to generate statistics for poker hands post-flop, and on the turn, like pot odds, hand odds, poker odds, outs, etc, I got the gui working, all I have to do is get the buttons in the app working, but all my classes are written and are working fine.

View 3 Replies View Related

Programming :: Reading Lines To An Array And Generate Dynamic Zenity List?

May 18, 2011

explanation what I want to do exactly:I have a textfile which looks for instance like this:

file.txt:
...
something=else to do

[code]....

View 14 Replies View Related

General :: Convert Full-disk RAID5 Array To Partition-based Array?

Dec 23, 2010

I have a RAID 5 array, md0, with three full-disk (non-partitioned) members, sdb, sdc, and sdd. My computer will hang during the AHCI BIOS if AHCI is enabled instead of IDE, if these drives are plugged in. I believe it may be because I'm using the whole disk, and the AHCI BIOS expects an MBR to be on the drive (I don't know why it would care).

Is there a way to convert the array to use members sdb1, sdc1 and sdd1, partitioned MBR with 0xFD RAID partitions?

View 1 Replies View Related







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