Programming :: Move A File In C?
Apr 17, 2011I'm trying to move a file in C, but I guess there is a simple method to do this in libc!
Somebody knows how can I do this on libc, or using some "default" method?
I'm trying to move a file in C, but I guess there is a simple method to do this in libc!
Somebody knows how can I do this on libc, or using some "default" method?
Initially I thought - use a for loop with ls in it:
Code:
However this causes lots of problems (folders have extensions, I have duplicate folders, the names with spaces create a folder for each element of the name).
The contents of the folder is basically movies (some with subtitles). Some of the names have things like (original) or CD1 CD2 in them.
i want to move the text of a file to another file,using sed command. how can i do it?
View 1 Replies View RelatedIs there a valid way, or trick to move the EOF indicator of a file? For example the file contains the data:
Code:
I am asking question.
0123456789
This is the example content of the file.
End is after the period.
I want to move the EOF after the number 9 so that when I read the file it will now contain:
Code:
I am asking question.
0123456789
Is this possible? Language to use is C.
I've got a bash script I'm using to download a text file list of links via axel. What I'd like to do is automate the movement of completed links in the for loop when axel has successfully completed the download. This is what I've got. I can figure that I can just echo append the line to a new file, but what is the easiest way to delete the line with the link I just downloaded?
Code:
#!/bin/bash
for i in $( cat $1); do
axel --alternate --num-connections=6 $i
export RC=$?
[code]....
I have a pipe delimited flat file, field 27 is price. I would like to move items marked sold to a new file every couple months.
awk -F"|" '$27 == "SOLD" {print $0}' awktest2.data >> awkout2.data
Allows me to write line to new file but I need to delete the original line, I also want to make sold case insensitive tried [Ss][Oo] with no luck
make the move away from programming with windows. I have just downloaded the souce code to the Fluid FLTK GUI designer version 1.3.0. and i am completely lost. It just a huge pile of folders to me i don't know where to start how do I compile it ect....? Can anyone with experience maybe give me some pointers on how the most productive way to go about reading open source metarial is? like are there any files with classic names i should be looking for in particular?
View 9 Replies View RelatedCurrently I have an issue with a html page with css layout. I use div blocks to visualize servers within a blade enclosure on a html page. Some servers are fullsize, others are halfsize. The css layout looks ok unless the second row misses some elements. I would need a div that I can use as placeholder so that neighbor divs are placed in the right column. Those placeholder divs should be overlapped by divs from row1 that are bigger in size.
Example: For example if bay 3 and 4 of row1 are occupied by a fullsize blade, 2 divs in 3 and 4 will be missing. The result is that the divs that should be displayed in bay 5 and 6 are placed in bay 3 and 4 instead of bay 5 and 6 where they would belong. Because the "empty space" divs are non overlapable, the "fullsize" divs from row1 column 3 and 4 are truncated. They should span to the second row and the "empty space" divs in row2 column 3 and 4 should move right to column 5 and 6.
Code:
Erronous:
1 2 3 4 5 6 7 8
ROW1[L][x][L][L][x][x][L][L]
ROW2[L][ ][x][x]......[L][L]
Correct:
1 2 3 4 5 6 7 8
ROW1[L][x][L][L][X][x][L][L]
ROW2[L][ ][L][L][x][x][L][L]
[code]....
As this html page is automatically generated once a day, I need to use something like a div placeholder as I cannot easily modify the position of an individual element.
I'm in the midst of making a perl script and I was wondering if it was possible, to say, have a folder with 20 files in it, then move 5 files out of there, into a new one. I would like to to do this until the original folder has no more files in it, but I'm very stuck.
View 3 Replies View RelatedHow could i create a script that will move the mouse pointer around the screen.i'm thinking i need the Xlib modules (which i have installed) but don't know how to implement them
View 5 Replies View Relatedsed move to prev line if match
file:
desired result:
I need to make an image in drawing area move. I have a GdkPixmap which stores image of the drawing area. How can i copy a rectangle part inside GdkPixmap to other coordinates?
View 1 Replies View RelatedI was wondering if it's possible to move the known_hosts file from ~/.ssh/known_hosts to ~/somewhere/.ssh/known_hosts . I have a server running Plesk and the user home directories do not have write permissions (they do have write permissions within the subfolders, however).
I was able to move the authorized_keys file by editing sshd_config AuthorizedKeysFile , but when I try to log in without password, I'm still prompted every time if I want to add the host to list of known hosts, and it fails to save every time since it cannot write to known_hosts. Thus I am still unable to automate some processes. I'd like known_hosts to be located in the same location as my authorized_keys, which does have correct permissions for users.
I'm trying to move certain files to Trash using File Browser. I continually get this message:"Cannot move file to trash, do you want to delete immediately?"I am logged in under my user name; I (my user name) am the owner of these files; ALL permissions are on (rwx for owner, group, and other); and Trash is empty. Still I get this message.
View 4 Replies View Relatedhow to move a file over ssh to server but I cant get it back via terminal
Code:
scp Downloads/test8 user@host:home/user/Documents
moves it to server now i need to transfer back, I know I can do it with nautilus but i wanna learn terminal, I have googled but cant find what i,m looking for
OK I am trying to move a folder to a restricted area and it says I need root access, how can I get root access I been trying for ages and searching Google does not help because I am so new to Ubuntu I don't know what command lines mean or anything.
View 2 Replies View RelatedI have a directory , there are many files created in it , I want to use the command to move the files which elder than 30 days and gzip it and then move it to /tmp , and then remove those files , I tried use below command but not work.
find ~path -type f -mtime 30 -exec tar -zcvf - {} --remove-files > /tmp/oldfile.tgz ;
I want to move a big file (92gb tar) from a server to a new one
What's the best way to do this? I did try scp username@<xxx.xxx.xxx.101>:</home/xx...les/ani.tar.gz>
Which I found on the web somewhere but it did not work for me
I've tried a number of suggestions found on the internet and none of them work. Here's one:Code:mv "$x" ~/.Trash/...where $x is the pathname of the file passed to the script.I've also tried different paths to Trash - on Desktop, in Home folder, in my user folder, it makes no difference. Either nothing happens, or more often, the file is simply copied to my desktop or userfolder with the name "Trash".What is the actual path to the Trash folder and how can I move files there? I'm using Ubuntu 10.04.
View 1 Replies View RelatedI have a script that checks a folder for zip files than moves them to a different folder. I want to check every 5 maybe 10 seconds and since cron is setup to run at least a 1 minute increment I'm not sure how to do that time check as probably a loop within the script. One other thing is once the time check is in the script how would a cron job be setup to run this script? Once the script is running cron doesn't need to run it again, is there a feature to check if it's running and if it's not then run it?
find /export/xxxshare -name "*.zip" -exec mv {} /export/store ;
I have two servers on my network (at home). Let's call them A and B.
I have a small shell script that I have written on server A that zips up a file, backs up a database. It's triggered by cron once a day.
After I run it, I would like to move this file from server A to server B.
As I said, both are on the same network (in the same room, actually), and so obviously have different network IPs.
What are my options to move these files? It would need to be something that was done in perhaps a shell script that was, like the shell script that zips the files, is triggered by a cron job.
I'm assuming there are actual applications for this sort of theng (rsync?), but can it be done with a shell script? It seems very simple and basic...
How might this be done?
Systems:
Server A - CentOS v. 5
Server B - RHEL v. 4
how I can use the mv command to move a file that matches *.ext regardless of the case?
I would like to be able to move:
*.ext
*.EXT
*.ExT
....and so on with a single command. I do not want to have to type out all combinations of this single file extension in my script because my file system is case sensitive.
Im usign photorec to recover some files that i lost during a format to my hard drive.
The program works like a charm but put all the files on differents folders. i use the find command to put on a list the jpg files but how i use the cp or the mv command to move that files in the list to another folder?
This started happening last week. Whenever I try to delete a file that is not in my /home directory I get the message:
Cannot move file to trash, do you want to delete immediately.
I have found a couple threads in the forums about this issue, but it has always been associated with windows or samba shares.
This is happening on my computer, not on a shared folder or through samba. Its a little frustrating to say the least.
I have to move files between two file systems /inst and /inst2.When I perform 'cp -a /inst /inst2' it copies everything even hidden files and preserves access permissions.But when I perform 'mv /inst /inst2' it also preserves access perms and moves everything besides hidden files.Questions :hy is so ?What tool to use when moving file systems from one fs to another (rsync) ?
View 8 Replies View RelatedI have a file of 200 pages. I want to move my cursor page wise. Suppose I want to move my cursor from last page of the file to up three pages.Is there any command to do it or I use "k" to move up?
View 3 Replies View RelatedI am new to Linux and not sure how to explain what I want to do, but I will give it a try. I have a system running CentOS 5.x on a system the is dying. Is there an easy way to migrate the system over to a brand new system that I recently purchased? I only have / and swap partitions, so nothing fancy; however, I have read that Linux is nothing like Windows when it comes to applications, and I could simply drag and drop files on the new server; however, I suspect that there is more involved than that. I hope I can just move the files over, and the system will boot; however, I am worried about new hardware on the new system. I am looking for recommendations to this issue. I am not sure if I have described it correctly; however, just point anything out that I need to change.
View 5 Replies View RelatedI just got a new laptop and installed 11.1, and I want to move my swap file to a 8GB SD card I have. It seems to run very fast, so it will improve swapping speed. I created a swapfile with Partitioner, and I can delete the existing swapfile with GParted during a reboot - but I'm afraid I will make my system unbootable by doing that - don't I need to first tell OpenSuSE what swapfile (on the new sdb) to use? I'm pretty sure it will detect the new swapfile automatically during boot, but it might choke on a missing (old) swapfile.
View 6 Replies View RelatedIn order to protect myself if I make a mistake in typing a directory/filename path, I am searching for a way to prevent mv from doing anything if the source and destination files exist on separate partitions.I see no options in the man page.I just need to find a way to get the partition the directory/file is on
View 1 Replies View Relatedthe system currently have a directory with all the invalid files. how bad is it to move a single file to a directory containing 3 million files already?
View 2 Replies View Related