General :: Copying A Block Of Lines With Criteria?
Jan 27, 2011
I am having a file filled of blocks like (each is seperated with the <event> )
<event>
8 1 0.1118800E-04 0.1709000E+03 0.7546772E-02 0.1182204E+00
-1 -1 0 0 0 501 0.00000000000E+00 0.00000000000E+00 0.40846782627E+02 0.40846782627E+02 0.00000000000E+00 0. 1.
2 -1 0 0 501 0 0.00000000000E+00 0.00000000000E+00 -0.90202563950E+03 0.90202563950E+03 0.00000000000E+00 0. -1.
[code]....
how can I copy this block if for example find "13" in the first column and "-1" in the last ? Then, looping to the rest of the file doing the same all over again?
View 14 Replies
ADVERTISEMENT
Apr 23, 2010
Consider a situation in which you want to display only specific lines of contents from a file or of a command's output. Yes, we have head and tail commands. But, how to view all the lines of a file except the last one or vise versa when we don't know the count of lines in advance?
Consider this output:
Code:
[root@localhost ~]# ps au | grep bash
root 6316 0.0 0.0 4672 1440 tty1 Ss+ Apr22 0:02 -bash
root 20847 0.2 0.0 4672 1432 pts/0 Ss Apr23 0:12 -bash
root 21167 0.0 0.0 3920 660 pts/0 S+ 01:00 0:00 grep bash
Here, I don't want the last line (in italic) to be included in the result since the last line is due to "grep bash" in the devised command "ps au | grep bash". Well, we can rewrite the devised command:
Quote:
"ps au | grep bash | head -n 2"
But, again, here we are specifying the count of lines to be included. But, in the presented problem we don't know any count in advance!
View 6 Replies
View Related
Mar 5, 2010
Suppose that I have this text :
1 abc
2 def
3 ghi
4 klm
Now I want to copy(yank) only the parts:
ab from line one and hi from line three at the same time
So how can this be done with vim? I know how to copy one line and one part of a line. What I want to do is to copy two parts from 2 different lines at the same time and paste them as they are some where else in the file.
View 4 Replies
View Related
Apr 23, 2010
I tried to get a block of lines in awk, but unfortunately it returns output of one line only. I don't state the code here, because it's too short and too poor. What exactly I wanted to do: from file "/boot/grub/menu.lst" get blocks of lines, starting by title and ending by Now I have just
Code:
script="/boot/grub/menu.lst";
OLDIFS=$IFS; IFS=$'
';
[code]....
I want to get every block as one row of array.
View 14 Replies
View Related
Dec 19, 2010
I'm struck with the following problem.
I have a data file with following data code...
(I have bigger data that needs to check all the above conditions)
get a code for the above problem
(either a shell code or a c-program)
View 2 Replies
View Related
Dec 15, 2010
I have a clump of text that needs to be broke up:gdbm Sat 07 Feb 2009 03:28:18 AM EST libattr Sat 07 Feb 2009 03:28:18 AM EST db4 Sat 07 Feb 2009 03:28:19 AM EST mktemp Sat 07 Feb 2009 03:28:19 AM EST keyutils Sat 07 Feb 2009 03:28:20 AM EST pcre Sat 07 Feb 2009 03:28:21 AM EST setserial Sat 07 Feb 2009 03:28:24 AM EST zlib Sat 07 Feb 2009 03:28:24 AM EST gawk Sat 07 Feb 2009 03:28:25 AM EST readline Sat 07 Feb 2009 03:28:26 AM EST rhpl Sat 07 Feb 2009 03:28:28 AM EST cracklib-dicts Sat 07 Feb 2009 03:28:37 AM EST setools Sat 07 Feb 2009 03:28:37 AM EST hal Sat 07 Feb 2009 03:28:38 AM EST which Sat 07 Feb 2009 03:28:39 AM EST Is there a way to get everything after the EDT in the text to be moved to a new line?
View 13 Replies
View Related
Jul 6, 2010
I have a few FTP users on my linux server(running vsftpd). They all have their own directory and can upload and delete files in that folder.Now, I was wondering whether it would be possible to create special permissions/rights for users. For example, I would like to make it so that certain users could not upload .exe files, or I want a certain user to only be able to upload image files (gif, jpg).
View 2 Replies
View Related
Sep 11, 2009
I have several files with many lines something like this:
I'm trying to write a script that will count the number of characters per line that doesn't contain a ">" symbol and give me an average of those values. I have most of the script together but I can't figure out how to connect some of the steps.
Code:
View 3 Replies
View Related
Jan 26, 2010
I've come across an unusual requirement for a service in my Ubuntu system.Simply put, I need to find a way to search for all instances of a term in a file, delete lines containing containing that term, and delete four lines below each instance of that term. ither that, or copy the entirety of a file to a new file and skip over all lines containing the term plus four below it.This sounds kinda weird, I know. Without going too far into detail, I either have to change the logfile format for a server I'm running which is a huge pain in the butt, or I can just run a script to edit an HTML report generated from said logs. (Said report is really just for managers to peruse, and I like my log format, so I'm pursuing option 2.)
View 4 Replies
View Related
Jun 21, 2011
I'm here of course because I would like to know what would be the SSH command to issue if I need to delete certain files that meet certain criteria. For instance, in this case, I simply have files that almost bear the same name but still have some very minor differences.
Let me give you an example:
L0619000.log
L0619001.log
L0619002.log
L0619003.log
L0619004.log
Those in bold are those I'd like to have removed, while the "L0619004.log" is obviously to be left intact.
View 3 Replies
View Related
Apr 22, 2011
I have been experiencing a problem where the screen loads and after initial first few lines breaks up into multiple repetitions of lines. Reloading helps but has to be repeated when pageing down. Mail is no problem; it is supplied by my network provider. OS is openSUSE 11.2 which I update when advised. Below is a sample from the error console:
[Code]...
View 1 Replies
View Related
May 31, 2011
I've just installed Kubuntu 11.04, switched on wobbly windows effect. It runs very smooth on my Nvidia GeForce 7600 GS with dual screen twinview turned on. However, I get these lines when I drag/move the window upwards - see screenshot:
View 6 Replies
View Related
Nov 24, 2009
How do you remove parts of strings using python? Such as, if I have something like:
Code:
erme1 sdifskenklsd
erme2 sdfjksliel
[code]....
View 3 Replies
View Related
Oct 26, 2009
I have this massive table file with some data in it and I want to replace some lines that are wrong with the correct ones that are in another table file of the same format. The wrong lines are not all together in a block but randomly distributed so I need to make a loop checking if the line is in the other file and if it is, replace it. I want to try and do it with sed or awk but I don't really know how to....
View 12 Replies
View Related
Dec 8, 2009
The most recent flavour of Linux I've been using has been Sidux, but the update cycle in sid is a little too fast for my liking.
What I'm looking for:
- Debian Based
- KDE 4.X
- Ideally it would still be able to use debian archives (ie like sidux)
- Updates less often than sid, so you aren't a long way behind if you miss a week, but often enough to still have up to date versions of software.
View 9 Replies
View Related
Jul 4, 2011
I have a tube type stereo amplifier (Eico ST-70) and a Empire Troubador turntable, both from 1963. I would like to be able to copy the LP's to CD using Linux.
View 1 Replies
View Related
Nov 9, 2009
I want to create a script which will show the amount of data that is been copied from one location to another location. For example: Say I have a file called abc.img which is approximately 4 gb of size therefore every time I copy the file from one location to another I want a progress bar to appear like 50% completed 51% completed and so on.
View 2 Replies
View Related
Dec 18, 2010
In cdrecord's man page, EXAMPLES, it says:
Quote:
To copy an audio CD in the most accurate way, first run
cdda2wav dev=2,0 -vall cddb=0 -B -Owav
and then run
cdrecord dev=2,0 -v -dao -useinfo -text *.wav
Now, cdda2wav samples the drive output. But the signal is already sampled in the CD. Do you think this is accurate?
View 7 Replies
View Related
May 9, 2011
I want to copy my /home to a USB thumb drive recursively. I've wrestled with this for a few hours now and continue to spin my wheels.The device is listed in my Disk Utility as /dev/sdc. However a little further down it is listed as /dev/sdc1 ? Anyway, I relabeled the volume as usb stick and formatted it to Ext4. I mounted it at /media/usb stick Do I have to enter this drive into the fstab? If so, how? what do I write? Using the command : cp -R (what follows... I want to copy /home recursively to the usb thumb drive.)
View 8 Replies
View Related
Jun 7, 2010
I have a new network attached storage unit that I'm trying to transfer my data to. On this NAS, it has a very basic linux installed with SSH enabled. Browsing through the programs installed on it, i found smbclient. Am I able to copy files directly from my old NAS to my new one using smbclient?It would sure beat transfering 950GB from my old NAS through a computer then onto my new NAS.
View 1 Replies
View Related
Nov 4, 2009
copying permissions from one file to another.I know that command for changing permission is "chmod", for example chmod 666 filename However, I have one file filename1 and by listing all contents of a directory with ls -al I can find out its permissions in form -rwwx and similar. Now I want to define exact same permissions to other file "filename2". How to use chmod command to accomplish this. Other way around would be to simply copy permissions from one file to another. Is there any command for this purpose?
View 3 Replies
View Related
Jul 25, 2010
The current directory contains:A file called "original.txt" Many directories called "source_001", "source_002", "source_003" ... From the command line how do you copy "original.txt" to "source_001" and "source_002" and "source_003" ...
The total number of these source directories is unknown, it changes every week.
View 4 Replies
View Related
Jan 3, 2011
How can I copy some files from a windows machine to Linux machine ?
View 13 Replies
View Related
Jan 16, 2010
I am running openSUSE 11.2 KDE 4.3.4 on my ThinkPad R51 laptop.I would like to copy 'File A, File B, File C' (for example) that has photographs of a holiday , to a blank CD inserted into my drive and cannot find a way to 'copy and paste' into the volume.
View 3 Replies
View Related
May 15, 2010
rather by accident, I copied a file to a USB drive by saying
cp <file> /dev/sdb1
rather than
cp <file> /media/USBDISK
I was surprised that this was at all possible (without root privileges and all), but now the drive cannot be mounted.
I did a
dd if=/dev/sdb of=corrupted.disk
but I don't know how to recover the data.
View 2 Replies
View Related
Jul 19, 2010
Linux kernel 2.6, slackware 12.0
KDE 3.5.7
I have some directories whose owner is root. When I enter the GUI (KDE) I always do it as normal user john. But then, when I want to copy a file to some of root's dirs, I get an "Access denied" notification. To be sincere, these dirs are in a window$ vfat partition and I can neither change the ownership nor the permissions. So what I do is to switch to a root console and painstakingly type the whole path of both source and destination, with the help, of course, of tab completion. To su to root, copy the file and exit to john would be much more comfortable. But I don't know how to do it. If I do K Menu>Run Command and type 'su root' nothing happens.
View 6 Replies
View Related
Apr 23, 2011
How can I do it in ubuntu? OpenOffice 3.2: File - Export to PDF -> Password on copy and print doesn't help. After exporting I can easily copy text from PDF file
View 10 Replies
View Related
May 17, 2010
I just read the Linux scp command issue question and it reminded me that I regularily forget to specify the colon in the host part of a scp command, and thus copying a file locally instead of copying to a remote host, e.g. I do
scp foo host
instead of
scp foo host:
But I never use scp to copy a file locally. So I wonder if there is a way to make scp fail if both (the source and destination) arguments refer to local files.
View 1 Replies
View Related
Jul 19, 2010
I want to copy part of a file I'm writing in emacs into, say a blog post or something like that. Putting the text into the kill ring doesn't allow me to paste it into another program. As it stands, I have to open the same file in gedit and copy/paste from there. Is there an easier way?
[Weirdly, it works fine the other way round: copying text off a SU answer, for example, I can paste that into emacs with C-y just fine...]
View 2 Replies
View Related
Mar 7, 2011
Is it possible to copy a file on multiple remote machines through scp in one command?
View 3 Replies
View Related