Software :: Divide A Big File Into Small Pieces, Each Has Same Number Of Lines?
Oct 16, 2009I am wondering if there is some command (sed ?) that could do divide a big text file into small pieces, each of which contains 10 lines
View 1 RepliesI am wondering if there is some command (sed ?) that could do divide a big text file into small pieces, each of which contains 10 lines
View 1 RepliesI'm looking for a way to insert the number of lines in a file to the start of the aformentioned file. This should be simple but as I am not used to scripts in Linux, I am finding it tough going. I can find the number of lines in a file easily enough via
filesize=$(awk 'END {print NR}' $1)
but as for inserting this into the first line, i'm failing to do so. I've tried some of the other approaches on these forums but none so far have been able to do so.
I've tried:
sed '1i$filesize' $1
but sed i requires a string, not a variable so no go I've also tried:
mv "$1" "${1}.bak" 2>/dev/null || touch "${1}.bak"
cat $filesize "${1}.bak" >"$1"
but again with no luck as cat seems to need an input stream Just to recap, i want to insert a line at the start of a given file that holds the number of lines the original file has.
ie the file:
a
b
c
d
e
should become:
5
a
b
c
[code].....
I recently found myself in possession of a large file (a few million lines in length) of short strings and would like to count the number of lines that are unique to the file. I thought this would be an easy process, but while working on the problem, I encountered the following. Can anyone explain this weird result to me?
Code:
alaric@alaric-laptop:~/Documents/Programming$ grep '^string$' file.txt | uniq | wc -l
1
[code]....
I need to create a script to count the number of lines from a text file . The output must be put on another text file (no_lines.txt) and in this file i need to generate from the script this output :"File $FILE has $NO_LINES lines ".
View 3 Replies View Relatedi need to count the number of files and put the output into a variable. i used wc -l filename but i couldnt find an option to put the output to variable. example if the number o line is 5, i need the output of echo $x is 5.
View 3 Replies View RelatedI have noticed that there are some tiny white scanlines over the screen in linux, is this something known? specific graphics cards? just an issue with my setup?
Its hard to explain but its even horizontal scanlines, like small white lines over the screen, like every 3 line... was wondering if its my geforce 8800 or what it is?
I am not sure if this is really a Ubuntu question but lets try it!Received email shows a long header which includes lines of code. I can scroll through it but I can't reduce the number of lines on screen.This significantly reduces the number of lines available for the message. There must be a way to reduce or eliminate this header.
View 2 Replies View RelatedView the entire contents of the file / etc / passwd, showing first 10 lines of file / etc / group, 10 displayed the last line of the file / etc / group. And
- The total number of lines and characters in file pwd and grp
I want to count the lines of all files in this directory and all its subdirectories, but exclude directories "public", "modules", and "templates".
View 2 Replies View RelatedI'm running a find. -name pattern to find some files, and I'd like to elegantly get the total number of lines in these files. How can I achieve that?
View 4 Replies View RelatedI 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 RelatedI would like to parse an input file in which there are two columns per each row. We want to see how many lines are duplicated where we define duplicate to be having the same second field and different first field. For instance if the input file looks like the following:
79874 13131
79873 12309
79820 13131
[code]...
I was having no problems (that I knew of) browsing the web since installing Ubuntu 10.10 a week or so ago. I was previously trialling Win7 as my customers will likely be using that in the future. Then I wanted to go to internode.on.net. Got the following: Quote: Firefox can't establish a connection to the server at internode.on.net. or Quote: Oops! Google Chrome could not connect to internode.on.net
As it was just after Christmas I thought it must be down, for upgrades or maintenance etc. I later tried to go to Freebsd.org; same error. I've been having a small number of other websites give the same error. I thought nothing of this until I tried it on my wife's macpro. I could log onto all the websites I wanted to and none gave any indication of having been down. Both boxes are on the same adsl connection. I still can't access internode or freebsd on 10.10 yet have been able to access every website on OSX. Now, I was only looking at them for info but am worried I won't be able to access something important. (so far everything I 'need' is working)
ping just drops out. edit: weirdest thing! I just retried and now can not emulate the problem for internode. freebsd still won't show. that is less than five minutes between problems and resolution! I hadn't even posted! But I still would like to have an idea of what is going on. Here is the ping error for freebsd: Quote:
[Code]...
Is installing "php5-suhosin" from yast and restarting apache enough to make suhosin work out of the box? Or do I need to add few lines to php.ini file and modify suhosin file?
View 3 Replies View RelatedHI am facing the strange issue in netbeans on ubuntu 9.04. whenever the file contains more than 3000 lines the characters overlap on each other and the file is not readable, where as if the file is less than 3000 lines it works fine. what may be the reason ?
View 2 Replies View RelatedI am using RHEL 5.I have a very large test file which cannot be opened in vi.The content of the file has some 8000 lines.I need to view ten lines between 5680 to 5690.How can i view these particular lines in a large file.what is command and option i need to use.
View 1 Replies View RelatedI am trying to delete lines of a file if they contain text that is present on another file. For example
> cat one.txt:
a
b
c
d
[code]....
I get the following output:
> ./test.sh one.txt two.txt
a
b
d
e
[code]....
I have a small lan network. I known the passwords of all and I want to scp a file to all and I don't want to give password each time. Is there any way for that through writing script.
View 1 Replies View RelatedI am having a big /home partition. I need to make it small and create one more partition from it which will be used for some other purpose. Can you tell me please how to do it?
I searched on google and found some methods which were very different from each other.I don't know which one is good, so, I thought I will ask you experts before doing anything.
i have two files with thousands of line, I am trying to combine these two files but i want to insert each line of one file to the another file after certain lines. I am using awk with the following command but it does not work.cat file1 | awk ' { print $0; if (NR%3004==0) {print "file2"}}' > outputfile
View 14 Replies View RelatedCode:
cat ${SOURCE}/{start,universal,index,end}.txt > ${SERVER}/index.html
cat ${SOURCE}/{start,universal,02042010,end}.txt > ${SERVER}/02042010.html
[code]....
I need to be able to compress into multiple pieces while still being able to be read by someone else who has windows, I can only download unrar but not rar. Why is this?
View 2 Replies View RelatedOn my c shell, I use the alias p ls -lt; pwd to speed up things while switching directories and getting their listings.Things could be much easier if I could somehow divide the space I have on my console in two parts such that the prompt is in the lower part and the top part always shows the listing of the current directory (the directory which I am using in the second part).The upper part needs to be dynamic in the sense that whenever I switch directories using the prompt in the lower part, It should give the listing of the current directory in the upper half.
View 3 Replies View RelatedHow to divide hard disk to install suse 11.
How many partition I have to choose
What kind of format;ext2 or ext3
I love the look of FreeNAS, but it does'nt do print server!
Must Have:
Run off a USB Flash Drive
File share with Windows (I want to backup to it)
Be a print server to a laser printer (USB interface)
Be remotely controlled once it is setup(don't have a spare screen and it's going in a spare room/corner BUT I will need to use a GUI for setup)
Free (thats why I won't use Windows)
Run OK on a P3
Preferred:
Power management
Wireless adapter compatible
Should the swap file be as large as possible or as small as possible providing a person has 8GB of installed ram.
View 14 Replies View RelatedI have this problem.I need to do this:I got a small version of Linux installed in some small devices. These devices come from the provider with this small version of Linux installed.This devices should send data to some other machine in the internet. I have tested wput for this purpose with a PC which has an Ubuntu version 10 and it works fine. However, when I try wput in the small device, I get an error. It seems that the wput might need some libraries to work with the small version of Linux installed in the small device.The fact of using wput or not is optional. I just need being able to send files through ftp with this small version of Linux.The thing is that to be able to run wput in this small version of Linux, it seems that many of the needed libraries were missing. So what I did was just install all the needed libraries. But still the wput program fails in its first line.
View 14 Replies View Relatedhow to Divide Equal Bandwidth between / Among Network Clients? e.g if there is total bandwidth = 10Mbps and only 5 clients are online then bandwidth should be divided evenly i.e each client to 2Mbps and if 20 clients are online then 0.5Mbps to each client automatically. [in windows this can be done by bandwidthcontroller software now how it can be done in linux]
View 3 Replies View RelatedI need files to be <= 5GB to put on S3. Right now I have an ugly tar / gzip / cut before upload, then cat / zcat / tar on download, but it's really ugly - and nearly every archiver should support archive splitting right? What's the best way?
View 2 Replies View RelatedCan the SFQ queue be used to divide bandwidth not only per connections but also per computer? E.g. if two computers download something each computer gets half of the bandwidth. I'm trying to do my own script based on wondershaper and would want to divide the bandwidth between all devices so that one device can't saturate the uplink.
View 2 Replies View Related