OpenSUSE :: Append Text To An Entry In An Existing File?
Aug 30, 2010
How do you append text to an entry in an existing file? For example, lets say I have a file called "env.logon" in /home/myself/bin that contains the following text:
PATH=/bin:/sbin If I wanted to add, via command line, ":/usr/bin:/usr/sbin" to the PATH= and I
used the "echo" command (echo "PATH=:/usr/bin:/usr/sbin) it would create a second entry and my file would look like:
PATH=/bin:/sbin
PATH=:/usr/bin:/usr/sbin
What I want is for it to look like:
PATH=/bin:/sbin:/usr/bin:/usr/sbin
Is there a way to get this result via command line?
Now I want to append contents list2.cfg to list1.cfg(It ispposible using cat list2.cfg >>list1.cfg) but I want to check if content of (record) in list2.cfg is present in list1.cfg then dont append it otherwise append it.
I want to append some text to the file, files are mostly big, more then 100 mb. I found the cat command, so I can create a new txt file and then append it to the original file with it. Two questions:
1. Can I append text to the file instead of creating the new file and then appending it to the original file? eg: Code: cat file.avi "some text" > newfile.avi 2. cat takes several seconds to execute the merging files together, it seems that it is reading the original file first, is there a way skip the reading and just append the file?
Say I have a text file like: Code: 1 3 4 How would I use ksh to put the number '2' into the second line of that file?Okay it's not bash, it's ksh because this computer is OpenBSD
I am thinking of appending something to each line in a text file with Java. I prefer not write a new file with content appended from the old one.That 'something' would probably be Time Stamp when the file is created (which is same for each line).I am not sure Java provide some easy way for it or not
may be an advanced question but I need to know how to do this. Here at work I am in charge of recruiting and we have about 1,000 resumes in already. All of the resumes are in a .pdf format. I need to rename every .pdf in the following format:{firstnameLastname}.pdfThe only way I know how to do this is to convert all the .pdf files to text, extract the name out of the first few lines of text, import into excel, and then use VBA to rename the files in mass:Here is my logic so far:~Deskop/a = houses all the .pdfresumesOpen terminal: Code: cd ~/Desktop/afor f in *.pdf; do pdftotext -raw $f; done That will convert all of the preceding resumes into text filesNow I would like to append the name of the text file into the last line of the text file. So, for example, for Resume1.txt, I want to append "Resume1.txt" to the last line within Resume1.txt. So after I run the command I open Resume1.txt and on the last line within I want to see "Resume1.txt" on the last line, at the end of the resume.How can I do this? I would like to use a loop and have the terminal append the filename to the body of the text file until all of the have been appended.
Will unzipping always append files if the directories already exist? What about tar?
I unzipped an archive the archive had 3 folders and dozens of subfolders within those. app, skin, js
The folder I unzipped it to also already had those 3 folders as well as many child folders etc.
My website is still working so I'm just wondering. Is this safe or is there anything I should worry about. The other option was to manually upload each file manually that is in those 3 folders and the dozens of sub folders.
I'm doing an assignment for school, and while we have not yet learned regular expressions, my teacher would like us to use AWK to append text to certain lines in a file. What we've had to do is creating a listing of all links and directories in the /etc folder and place them in a text file. From this, we were to cut the first field (Permissions) and the ninth field (filename) and create another text file. Now the part that I'm struggling with is this and I'm not sure if I should be using sed or awk. We're supposed to ADD the text "DIR" to the beginning of any line that is a directory, and "LNK" to any that is a link, like so:
Obviously, I realize that the first character in the permissions denotes what sort of file it is, hence when I created my text file I used
ls -l | grep "^d" > file.txt and ls -l | grep "^l" >> file.txt
I'd like to learn how to properly do this, but struggling through pages on the internet hasn't been helping, nor has the --help command. Therefore, while I would like the answer, I'd also like to know what the heck I'm doing For example, I know I could delete lines with regex using d/[STUFF I WANT TO DELETE]/g (To get rid of all occurences) and I can substitute using s/foo/bar But I'm unaware of anyway to ADD text upon certain occurences, let alone two different circumstances.
then the string "some textstring " will be APPENDED to logfile.txt Is there a redirect way that in stead of appended, the string will be INSERTED at the top of the logfile.txt file ? If this cannot be done by redirecting, what would be the best way to insert the test-string at the top of the logfile ?
i have puppy 4.2.1 installed on my hdd and have frugal installed a older version inside the existing puppy and would like to add it to the existing GRUB menu
I had an extension i started making and had loaded in Chromium. Well i forgot to unload it and deleted the files for it. Well now Chromium crashes on startup saying it can't find the manifest file for it. How can i remove the entry for that in the extension cookies file?
I have a file, say abc.txt, whit some text lines.The I have a second file, say 123.txt where at a certain point one can read "WORD".I would like to append the whole content of abc.txt (as it appears in abc.txt) in the line after "WORD".
I know similar questions have been asked before but I cannot seem to get it to work.I have a file file.something.nhMMYY that i need to ftp (MMYY being Month and Year)I want to add something into the script to auto-magically insert the MMYY.
im trying to output a list of running processes via a shell script. At the moment i got this which outputs the processes to a text file called out.
echo $(ps aux) >>out
The problem is though, the processes are all just one big block of text which makes it hard to read. Does anyone know how to sort the output to a text file so that it prints to the text file at 1 process per line? I know its probably simple but im very new to linux.
I want to append data to a file where immutable flag is set..So i have tried this command chattr +a file_name to append data..But i am unable to append the data..
If I need to append a set (or sets) of data to a file(or files) on remote hosts what is the best mechanism by which to do that? My first thought was ssh but the command syntax to append to a remote file isn't clear to me. Can anyone point me in the right direction here?
an idea what might be wrong with fs 0x06 FAT16? I have a mobile, Sony Ericsson K750i, which was mounted in previous distributions without problems (up to 11.1). Now I use 11.2 and I am unable to mount it. I tried to do it via yast, but it says "non-existing or uknokwn file system" even it was recognized as 0x06 FAT16. I read that this fs is outdated, however still supported.
I put a text file on my desktop and added a couple lines of text with gedit. File type shows text/plain. Double-click opens the file in gedit which is what I want. I'm using the file to temporarily hold some snips of code that I copy from file to file, but when I copy some html into the file and save it, now file properties show it's text/html and a double-click opens the file in firefox, which isn't what I want. Is there some way to keep the file type from changing itself?