Search Results

Search found 342 results on 14 pages for 'mv'.

Page 8/14 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • system call in Ruby

    - by Niklas
    Ruby-help Hi. I'm a beginner in ruby and in programming as well and need help with system call for moving a file from source to destination like this: system(mv "#{@SOURCE_DIR}/#{my_file} #{@DEST_DIR}/#{file}") Is it possible to do this in ruby and which is the correct syntax? Thx

    Read the article

  • how to pass parameters to a linux bash shell

    - by chun
    hi i have a linux bash shell 'myshell' i want it to read two date as parameters, ex: myshell date1 date2 i am a Java programer, but don't know how to write a shell to get this done the rest of the shell is like this sed "s/$date1/$date2/g" wlacd_stat.xml tmp.xml mv tmp.xml wlacd_stat.xml thanks

    Read the article

  • How to pass parameters to a Linux Bash script?

    - by chun
    I have a Linux bash script 'myshell'. I want it to read two dates as parameters, for example: myshell date1 date2. I am a Java programmer, but don't know how to write a script to get this done. The rest of the script is like this: sed "s/$date1/$date2/g" wlacd_stat.xml >tmp.xml mv tmp.xml wlacd_stat.xml

    Read the article

  • Go - Using a container/heap to implement a priority queue

    - by Seth Hoenig
    In the big picture, I'm trying to implement Dijkstra's algorithm using a priority queue. According to members of golang-nuts, the idiomatic way to do this in Go is to use the heap interface with a custom underlying data structure. So I have created Node.go and PQueue.go like so: //Node.go package pqueue type Node struct { row int col int myVal int sumVal int } func (n *Node) Init(r, c, mv, sv int) { n.row = r n.col = c n.myVal = mv n.sumVal = sv } func (n *Node) Equals(o *Node) bool { return n.row == o.row && n.col == o.col } And PQueue.go: // PQueue.go package pqueue import "container/vector" import "container/heap" type PQueue struct { data vector.Vector size int } func (pq *PQueue) Init() { heap.Init(pq) } func (pq *PQueue) IsEmpty() bool { return pq.size == 0 } func (pq *PQueue) Push(i interface{}) { heap.Push(pq, i) pq.size++ } func (pq *PQueue) Pop() interface{} { pq.size-- return heap.Pop(pq) } func (pq *PQueue) Len() int { return pq.size } func (pq *PQueue) Less(i, j int) bool { I := pq.data.At(i).(Node) J := pq.data.At(j).(Node) return (I.sumVal + I.myVal) < (J.sumVal + J.myVal) } func (pq *PQueue) Swap(i, j int) { temp := pq.data.At(i).(Node) pq.data.Set(i, pq.data.At(j).(Node)) pq.data.Set(j, temp) } And main.go: (the action is in SolveMatrix) // Euler 81 package main import "fmt" import "io/ioutil" import "strings" import "strconv" import "./pqueue" const MATSIZE = 5 const MATNAME = "matrix_small.txt" func main() { var matrix [MATSIZE][MATSIZE]int contents, err := ioutil.ReadFile(MATNAME) if err != nil { panic("FILE IO ERROR!") } inFileStr := string(contents) byrows := strings.Split(inFileStr, "\n", -1) for row := 0; row < MATSIZE; row++ { byrows[row] = (byrows[row])[0 : len(byrows[row])-1] bycols := strings.Split(byrows[row], ",", -1) for col := 0; col < MATSIZE; col++ { matrix[row][col], _ = strconv.Atoi(bycols[col]) } } PrintMatrix(matrix) sum, len := SolveMatrix(matrix) fmt.Printf("len: %d, sum: %d\n", len, sum) } func PrintMatrix(mat [MATSIZE][MATSIZE]int) { for r := 0; r < MATSIZE; r++ { for c := 0; c < MATSIZE; c++ { fmt.Printf("%d ", mat[r][c]) } fmt.Print("\n") } } func SolveMatrix(mat [MATSIZE][MATSIZE]int) (int, int) { var PQ pqueue.PQueue var firstNode pqueue.Node var endNode pqueue.Node msm1 := MATSIZE - 1 firstNode.Init(0, 0, mat[0][0], 0) endNode.Init(msm1, msm1, mat[msm1][msm1], 0) if PQ.IsEmpty() { // make compiler stfu about unused variable fmt.Print("empty") } PQ.Push(firstNode) // problem return 0, 0 } The problem is, upon compiling i get the error message: [~/Code/Euler/81] $ make 6g -o pqueue.6 Node.go PQueue.go 6g main.go main.go:58: implicit assignment of unexported field 'row' of pqueue.Node in function argument make: *** [all] Error 1 And commenting out the line PQ.Push(firstNode) does satisfy the compiler. But I don't understand why I'm getting the error message in the first place. Push doesn't modify the argument in any way.

    Read the article

  • Bash: Is it ok to use same input file as output of a piped command?

    - by Amro
    Consider something like: cat file | command > file Is this good practice? Could this overwrite the input file as the same time as we are reading it, or is it always read first in memory then piped to second command? Obviously I can use temp files as intermediary step, but I'm just wondering.. t=$(mktemp) cat file | command > ${t} && mv ${t} file

    Read the article

  • How to perform gui operation in doInBackground method?

    - by jM2.me
    My application reads a user selected file which contains addresses and then displays on mapview when done geocoding. To avoid hanging app the importing and geocoding is done in AsyncTask. public class LoadOverlayAsync extends AsyncTask<Uri, Integer, StopsOverlay> { Context context; MapView mapView; Drawable drawable; public LoadOverlayAsync(Context con, MapView mv, Drawable dw) { context = con; mapView = mv; drawable = dw; } protected StopsOverlay doInBackground(Uri... uris) { StringBuilder text = new StringBuilder(); StopsOverlay stopsOverlay = new StopsOverlay(drawable, context); Geocoder geo = new Geocoder(context, Locale.US); try { File file = new File(new URI(uris[0].toString())); BufferedReader br = new BufferedReader(new FileReader(file)); String line; while ((line = br.readLine()) != null) { StopOverlay stopOverlay = null; String[] tempLine = line.split("~"); List<Address> results = geo.getFromLocationName(tempLine[4] + " " + tempLine[5] + " " + tempLine[7] + " " + tempLine[8], 10); if (results.size() > 0) { Toast progressToast = Toast.makeText(context, "More than one yo", 1000); progressToast.show(); } else if (results.size() == 1) { Address addr = results.get(0); GeoPoint mPoint = new GeoPoint((int)(addr.getLatitude() * 1E6), (int)(addr.getLongitude() * 1E6)); stopOverlay = new StopOverlay(mPoint, tempLine); } if (stopOverlay != null) { stopsOverlay.addOverlay(stopOverlay); } //List<Address> results = geo.getFromLocationName(locationName, maxResults) } } catch (URISyntaxException e) { showErrorToast(e.toString()); //e.printStackTrace(); } catch (FileNotFoundException e) { showErrorToast(e.toString()); //e.printStackTrace(); } catch (IOException e) { showErrorToast(e.toString()); //e.printStackTrace(); } return stopsOverlay; } protected void onProgressUpdate(Integer... progress) { Toast progressToast = Toast.makeText(context, "Loaded " + progress.toString(), 1000); progressToast.show(); } protected void onPostExecute(StopsOverlay so) { //mapView.getOverlays().add(so); Toast progressToast = Toast.makeText(context, "Done geocoding", 1000); progressToast.show(); } protected void showErrorToast(String msg) { Toast Newtoast = Toast.makeText(context, msg, 10000); Newtoast.show(); } } But if geocode fails, I want a dialog popup to let user edit the address. That would require calling on gui method while in doInBackground. What would be a good workaround this?

    Read the article

  • Rails, Rake, moving a folder to a new location

    - by Sam
    I need to move a folder from a plugin to the main app/views. I guess using rake to do this with the following command is the easiest way: require 'fileutils' FileUtils.mv('/vendor/plugins/easy_addresses/lib/app/views', '/app/views/') I'm just not sure where to tell script where to look and where to place the folder. The file I want to move is in the following location: `vender/plugins/easy_addresses/lib/app/views/easy_addresses easy_ addresses is the name of the folder in views that I want to move to my_app/app/views/

    Read the article

  • Type is undefined MVC AJAX Script

    - by zsharp
    on one page of my app i get a Type is undefined on the ajax script. why would this be? EDIT Type is not defined MicrosoftMvcAjax.js()()Microsof...vcAjax.js (line 6) [Break on this error] Type.registerNamespace('Sys.Mvc');Sys.Mv...reate_AjaxOptions=function(){return {};}

    Read the article

  • Appending rather than overwriting files when moving

    - by ukas1
    I have the following directory structure: +-archive +-a +-data.txt +-b +-data.txt +-incoming +-a +-data.txt +-c +-data.txt How do I do the equivalent of mv incoming/* archive/ but have the contents of the files in incoming appended to those in archive rather than overwrite them?

    Read the article

  • Makefile - How to save the .o one directory up?

    - by nunos
    Imagine the following folder structure: project src code.c makefile bin How can I compile code.c to code.o and directly put it inside bin? I know I could compile it to code.o under src and the do "mv code.o ../bin" but that would yield an error if there were compile errors, right? Even if it works that way, is there a better way to do it? Thanks.

    Read the article

  • how to get powershell to look for files in other folders when moving items?

    - by steeluser
    I have written this script to move files to the destination folder. Looks like I am missing something here because when I run the script, it is only looking for .zqx files in current directory and not all the drives. Please note that the ( dir $paths..) part is returning the list of .zqx files promptly. Paths.txt has drive letters like this C:\ D:\ E:\ $paths = get-content paths.txt mv (dir $paths -r -fi *.zqx | ?{$_.lastwritetime -lt ($sevendaysold)}) -dest e:\xqz Thanks Steeluser

    Read the article

  • How do I convert filenames from unicode to ascii

    - by zedwarth
    I have a bunch of music files on a NTFS partition mounted on linux that have filenames with unicode characters. I'm having trouble writing a script to rename the files so that all of the file names use only ASCII characters. I think that using the iconv command should work, but I'm having trouble escaping the characters for the mv command.

    Read the article

  • Ubuntu Bash Script changing file names chronologicaly

    - by Manifold
    I have this bash script where I am trying to change all *.txt files in a directory to their date of last modification. This is the script: #!/bin/bash # Renames the .txt files to the date modified # FROM: foo.txt Created on: 2012-04-18 18:51:44 # TO: 20120418_185144.txt for i in *.txt do mod_date=$(stat --format %y "$i"|awk '{print $1"_"$2}'|cut -f1 -d'.'|sed 's/[: -]//g') mv "$i" "$mod_date".txt done The error I am getting is: renamer.sh: 6: renamer.sh: Syntax error: word unexpected (expecting "do") Any help would be greatly appreciated. Thank you for your time.

    Read the article

  • Minecraft server Rkit ubuntu upstart [closed]

    - by user1637491
    I have an Intel server running Ubuntu Server 12.04.1 I am working on moving my CraftBukkit Minecraft Server to the new platform. I read the upstart ubuntu cookbook and wrote a .conf file I have a minecraft user (named minecraft) and its home Directory is /home/minecraft it contains prwxrwxrwx 1 minecraft minecraft 0 Sep 19 14:49 command-fifo drwx------ 8 minecraft minecraft 4096 Sep 19 14:50 HDsaves drwx------ 2 minecraft minecraft 4096 Aug 31 15:13 logrolls -rw-r--r-- 1 root root 5 Sep 19 14:49 minecraft.pid drwxrwxrwx 8 minecraft minecraft 180 Sep 19 14:49 ramdisk -rw------- 1 minecraft minecraft 119 Sep 19 10:34 save.sh drwxrwxrwx 9 minecraft minecraft 4096 Sep 19 14:50 server -rw-rw-r-- 1 minecraft minecraft 44 Aug 31 11:40 shutdown.sh the server directory contains drwxrwxrwx 6 minecraft minecraft 4096 Aug 30 13:32 Backups -rwxrwxrwx 1 minecraft minecraft 0 Sep 18 12:26 banned-ips.txt -rwxrwxrwx 1 minecraft minecraft 17 Sep 18 12:26 banned-players.txt drwxrwxrwx 4 minecraft minecraft 4096 Aug 30 12:26 buildcraft -rwxrwxrwx 1 minecraft minecraft 1447 Sep 18 12:26 bukkit.yml -rwxrwxrwx 1 minecraft minecraft 0 Aug 30 11:05 command-fifo drwxrwxrwx 2 minecraft minecraft 4096 Aug 30 12:26 config lrwxrwxrwx 1 minecraft minecraft 23 Sep 19 14:49 craftbukkit.jar -> ramdisk/craftbukkit.jar -rwxrwxrwx 1 minecraft minecraft 17419 Sep 18 12:26 ForgeModLoader-0.log -rwxrwxrwx 1 minecraft minecraft 17420 Sep 18 12:24 ForgeModLoader-1.log -rwxrwxrwx 1 minecraft minecraft 17420 Sep 18 11:53 ForgeModLoader-2.log -rwxrwxrwx 1 minecraft minecraft 2576 Aug 30 11:05 help.yml drwxrwxrwx 2 minecraft minecraft 4096 Aug 30 12:31 lib drwxrwxrwx 3 minecraft minecraft 4096 Sep 19 14:49 logrolls -rwxrwxrwx 1 minecraft minecraft 200035 Sep 4 17:58 Minecraft_RKit.jar lrwxrwxrwx 1 minecraft minecraft 12 Sep 19 14:49 mods -> ramdisk/mods -rwxrwxrwx 1 minecraft minecraft 5 Sep 18 12:26 ops.txt -rwxrwxrwx 1 minecraft minecraft 0 Aug 30 11:05 permissions.yml lrwxrwxrwx 1 minecraft minecraft 15 Sep 19 14:49 plugins -> ramdisk/plugins lrwxrwxrwx 1 minecraft minecraft 16 Sep 19 14:49 redpower -> ramdisk/redpower -rw-r--r-- 1 root root 255 Sep 19 15:10 server.log -rwxrwxrwx 1 minecraft minecraft 464 Sep 8 11:09 server.properties drwxrwxrwx 3 minecraft minecraft 4096 Sep 5 16:05 SpaceModule drwxrwxrwx 3 minecraft minecraft 4096 Aug 30 13:07 toolkit -rwxrwxrwx 1 minecraft minecraft 1433 Sep 14 21:04 wepif.yml -rwxrwxrwx 1 minecraft minecraft 0 Sep 18 12:26 white-list.txt lrwxrwxrwx 1 minecraft minecraft 13 Sep 19 14:49 world -> ramdisk/world lrwxrwxrwx 1 minecraft minecraft 20 Sep 19 14:49 world_nether -> ramdisk/world_nether lrwxrwxrwx 1 minecraft minecraft 21 Sep 19 14:49 world_the_end -> ramdisk/world_the_end the startup .conf file: # Starts the minecraft server after loading JRE from ramdisk # # for now im still working on it description "minecraft-server" start on filesystem or runlevel [2345] stop on runlevel [!2345] oom score -999 kill timeout 60 pre-start script sh /usr/lib/jvm/java.sh end script script cd /home/minecraft echo "$(date) Starting minecraft" sudo cp -r /home/minecraft/HDsaves/* ramdisk sudo chown -R minecraft:minecraft ramdisk sudo chmod -R 777 ramdisk sudo ln -sf ramdisk/* server sudo chown -R minecraft:minecraft server sudo chmod -R 777 server sudo mv server/server.log server/logrolls/ zip server/logrolls/temp.zip server/logrolls/server.log sudo mv server/logrolls/temp.zip server/logrolls/"$(date)".log.zip sudo rm server/logrolls/server.log sudo rm -f command-fifo sudo mkfifo command-fifo sudo chown minecraft:minecraft command-fifo sudo chmod 777 command-fifo echo "$(date) Root commands finished" echo "$(date) Starting Wrapper" cd server sudo -u minecraft java -Xmx30M -Xms30M -XX:MaxPermSize=40M -Djava.awt.headless=true -jar Minecraft_RKit.jar timv:*spoilers* <> /home/minecraft/command-fifo & sudo echo $! >| /home/minecraft/minecraft.pid echo "$(date) Minecraft Started" end script pre-stop script cd /home/minecraft PID=`cat minecraft.pid` if [ "$PID" != "" ]; then echo "Stopping MineCraft Server PID=$PID" sudo echo save-all >> command-fifo sudo echo .stopwrapper >> command-fifo wait $PID sudo rm minecraft.pid sudo rsync -rt --delete ramdisk/* HDsaves/ echo "$(date) ramdisk save complete" echo "MineCraft save-shutdown complete." else echo "MineCraft not running" fi end script so when I start it up the upstart gererated log says: Wed Sep 19 14:49:30 CDT 2012 Starting minecraft adding: server/logrolls/server.log (stored 0%) Wed Sep 19 14:49:56 CDT 2012 Root commands finished Wed Sep 19 14:49:56 CDT 2012 Starting Wrapper Wed Sep 19 14:49:56 CDT 2012 Minecraft Started

    Read the article

  • rename file names from lower case to upper case

    - by Adnan
    Hello, I have about 2k of file that are currently in lower case like: file_one.cfr file_two.cfr .... I am searching for a fast way to rename them to upper case so they would be like; FILE_ONE.cfr FILE_TWO.cfr .... If I use from my shell; for i in *; do mv $i `echo $i | tr [:lower:] [:upper:]`; done I can get all file and the file extensions to upper case. But the extension should remain in lowercase, so my approach does not work. Any programming language is welcome.

    Read the article

  • 12.04 ext4 - cannot create regular file/No space left - with a lot of space and inodes

    - by user1434058
    This seems similar: EXT4 "No space left on device (28)" incorrect but there is no explanation I created an ext4 filesystem on a RAID 1 array with: mke2fs -t ext4 -T small /dev/md0 Copying a single directory with many tiny files I get: cp: cannot create regular file `/mnt/raid1_new/pics/pic3412.jpg': No space left on device space used 5% inodes used 1% I manually tried: cp /source/test1.jpg /mnt/raid1_new/pics/test1.jpg --- error cp /source/test1.jpg /mnt/raid1_new/pics/test2.jpg --- ERROR cp /source/test1.jpg /mnt/raid1_new/pics/test3.jpg --- no error Notes: RAID 1 disks are error free. I tried mv instead of cp and got the same thing. I tried omitting -T small with no effect Can somebody help me understand this magic?

    Read the article

  • Why does redirecting "sudo echo" stdout to a file not give root ownership?

    - by orokusaki
    I'm pretty new to using Linux heavily, and I'm trying to learn more about file ownership and permissions. One thing that I stumbled on just now was exactly what the title says, running: weee@my-server:~$ sudo echo "hello" > some-file.txt weee@my-server:~$ ls -lh total 4.0K -rw-rw-r-- 1 weee weee 6 Dec 5 21:21 some-file.txt The file is owned by me, whereas touch works like one would expect: weee@my-server:~$ sudo touch other-file.txt weee@my-server:~$ ls -lh total 4.0K -rw-r--r-- 1 root root 0 Dec 5 21:22 other-file.txt How can I force the file to be created by root? Do I simply have to create the file in my homedir, then sudo chown root... and sudo mv ... move it to /var where I need it to be? I was hoping there'd be a single step to accomplish this.

    Read the article

  • Have rTorrent to move .torrent files

    - by David Alvares
    I am running rTorrent 0.9.2 and have configured it to move completed torrents to a different folder with this configuration line: system.method.set_key = event.download.finished,move_complete,"d.set_directory=~/done/;execute=mv,-u,$d.get_base_path=,~/done/" This is working fine, but I would like it to also move the .torrent file that it creates (from a magnet link into the session directory) into this done directory with the same name as the torrent and a .torrent extension. I tried adding another cp command, but I can not seem to figure out which variable ($d.get_hash did not work) stores the torrent's hash (which is what the .torrent files are named in the session directory). Is there a way to do this with rTorrent, if so how?

    Read the article

  • Weird bug in 'tar' not including files named .__init__.py

    - by Sridhar Ratnakumar
    Does anyone know why tar is not including files named .__init__.py (note the dot)? $ mkdir /tmp/work && cd /tmp/work $ mkdir foo $ touch foo/.__init__.py $ touch foo/.namespace__init__.py $ tar czf foo.tar.gz foo $ mkdir e && mv foo.tar.gz e/ && cd e/ $ tar zxf foo.tar.gz $ ls -al foo/ total 0 drwxr-xr-x 2 sridharr wheel 102 14 Mar 17:16 . drwxr-xr-x 3 sridharr wheel 136 14 Mar 17:17 .. -rw-r--r-- 1 sridharr wheel 0 14 Mar 17:16 .namespace__init__.py $ $ echo ".__init__.py file is missing. WTF? This is OSX 10.6"

    Read the article

  • execute a command in all subdirectories bash

    - by Luigi R. Viggiano
    I have a directory structure composed by: iTunes/Music/${author}/${album}/${song.mp3} I implemented a script to strip my mp3 bitrate to 128 kbps using lame (which works on a single file at time). My script looks like this 'normalize_mp3.sh': #!/bin/bash SAVEIFS=$IFS IFS=$(echo -en "\n\b") for f in *.mp3 do lame --cbr $f __out.mp3 mv __out.mp3 $f done IFS=$SAVEIFS This works fine, if I go folder by folder and execute this command. But I'd like to have a "global" command, like in 4DOS so I can run: $ cd iTunes/Music $ global normalize_mp3.sh and the global command would traverse all subdirs and execute the normalize_mp3.sh to strip all my mp3 in all subfolders. Anyone knows if there is a unix equivalent to the 4dos global command? I tried to play with find -exec but I just managed to get an headache.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14  | Next Page >