General :: Showing The Line Count Of A Specific File

Mar 30, 2011

Is this the correct way to show the line count of a specific file?

cat file | grep * -c

View 3 Replies


ADVERTISEMENT

General :: Splitting Text File Into Several Parts By Line Count

Sep 21, 2009

I have a utility that works with files. The utility is crashing at after about 120 files. The input to the utility is a file containing a filelist. I want to cut the file with the file names in it to seperate files containing about one hundred or so. My thought was to determine the number of lines/100 and then use head and delete to create temporary files to run the utility multiple times to prevent the crash. When I tried to create a variable using the wc -l command the output gives me the number of total lines but it also includes the filename of the input file. (873 Filename.txt) I can not figure out how to remove the Filename.txt from the variable.

View 2 Replies View Related

General :: Identify File Types - Command Line Arguments - And Count - How Many Of Them Are Regular Files

Feb 20, 2010

Write a script that will take a list of filenames as arguments and output a count of how many of them are regular files, and how many of them are scripts (if the file is executable, it will be assumed to be a script file)

Counts always come back as 0

View 5 Replies View Related

General :: Script To Count # Of Chars Per Line - If Line Meets Certain Criteria - And Get Avg #?

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

General :: Bash Script To Parse A File To Get A Set Of Line Between A Specific Characters?

Dec 23, 2010

I have a log file that contains information like this:

----------------------------
r11141 | prasath-palani | 2010-12-23 16:21:24 +0530 (Thu, 23 Dec 2010) | 1 line
Changed paths:
M /projects/
M /projects/

[code]....

what i need is, i need to copy the data given between the "---" to seperate files, for, e.g. the first set of data between the "---" should be in one file and another set of data in another file.

View 5 Replies View Related

General :: Removing A Line From File Which Is Having Specific Pattern Using Shell Script?

Mar 20, 2011

I'm new to the shell scripting. can any one help in creating shell script for matching the content of the specific variable with file. it should remove that line from the file if line is containing same value as variable and keep the other content as it is.i used grep -v for accomplishing the same. But grep will remove the pattern which is similar.For eg. Assume file "test" contain datas :aaffif i used grep -v command for the pattern "a" to this file this will remove content "aa" from the file. I want the pattern only "a" should remove from the file, if it is existing. otherwise it should throw alert content not exists.

View 5 Replies View Related

General :: Grep Command - Show The Files But Not The Line Count

Oct 31, 2010

This has to also show the line count. I can get it to show the files but not the line count. What is the single command used to identify only the matching count of all lines within files under the /etc directory that contain the word „HOST? List only the files with matches and suppress any error messages.

View 4 Replies View Related

General :: How To Delete A Line At Specific Line Number

Jun 15, 2010

I m writing a script to delete a line at particular location.

But i m unable to use variable for specifying line number.

For example.

Code:

works fine and deletes 7th line from my file

But

Code:

gives following error.

Code:

View 7 Replies View Related

General :: Command Line - Count Number Of Folders In A Drive Using System?

Apr 9, 2010

I need to organise an external HDD such that there is no more than 500 folders on it.

Ubuntu's "Properties" pane shows only the file count, not the folder count.

Is there a simple CLI line that will tell me the number of subdirectories?

View 3 Replies View Related

Programming :: Copy And Replacing Specific Line From File1 To File2 Line By Line

Mar 22, 2011

I have two files, file1.traj and file2.traj. Both these files contain identical data and the data are arranged in same format in them. The first line of both files is a comment.

At line 7843 of both files there is a cartesian coordinate X, Y and Z ( three digits ). And at line 15685 there is another three digits. The number of lines in between two cartesian coordinates are 7841. And there are few hundreds of thousands of lines in a file.

What I need to do is copy the X Y Z coordinate (three digits) from file1.traj at line 7843 and paste into file2.traj at the same line number as in file1.traj. The next line will be 15685 from file1.traj and replace at line 15685 at file2.traj. And I dont want other lines (data) in file2.traj get altered. This sequence shall be going on until the end of the file. Means copy and substitude the selected lines from file1.traj into file2.traj.

I tried to use paste command but I cant do for specified line alone.

Here i showed the data format in the file. I used the line number for clarity purpose.

Code:

View 10 Replies View Related

Programming :: Count Specific Entries Inside A Block?

Jul 15, 2011

What I want to do is from a file having block like

<event>
8 3 0.2685416E-02
2 -1 0
21 -1 0

[code]...

The first line after the "<event>" is its process-id, so I would like to have at the end a summary of how many "event" block I have for each type, ie how many

6 1 0.2685416E-02

or how many

7 2 0.2685416E-02

etc etc

I do not know in advance how many different-kind of block I will have, so it has to be a bit smart to scan the file, and make an new "summary" info for each unique type I was using something like

awk '/<event>/,/</event>/{if ($3 -eq 0.2685416E-02 ) { print $1" "$2" "$3}}' file > out

and then

grep -c "$1" "$2" "$3" but with no success since my awk commands prints all lines of each block

Suppose, that in advance I do know the $3, ie the 0.2685416E-02 which is a kind of weight

View 8 Replies View Related

General :: Parse File From Remote Server To Caculate Count Of String Existence In That File?

Aug 30, 2010

I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files.Say a file abc.log exist on 2 servers.I want to search for string "test" on both files and calculate the total count of search string's existence.For example if file abc.log on server 1 has string "test" 2 times
and file abc.log on server 2 has string "test" 4 times.then the output will beStringName : Countexampletest : 6 timesNote : I have created the password less connectivity using ssh-keygen.

View 2 Replies View Related

Programming :: Bash Script To Count Number Of Lines With A Specific Property7?

Aug 11, 2010

I 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]...

View 10 Replies View Related

Programming :: Replace Specific Character After Specific Line By Awk?

Jul 19, 2010

I want to replace specific character in a file after every specific line. example as follows.

O 000000000000000000
A 111111111111111111
C 222222222222222222

[code]...

View 2 Replies View Related

General :: How To Enter Value On A Specific Line

Feb 18, 2011

I am starting to learn shell programming, but I couldn't accomplish a simple thing that can be done with sed, awk.Its simple, I am dynamically getting an IP number, and a rule name, that I need to save them on a single file on a specific line number.I found how to enter a value on a specific line, but couldn't understand how to enter the second value.

View 3 Replies View Related

General :: Command To Count All Characters In File

Mar 26, 2010

Anybody know and command to count any characters in file? I would like to know the total number of character " (quote) in file. My idea is to check if in a script the total number of this character is pair.

View 4 Replies View Related

General :: Count An Item In A Tab-delimited Txt File?

Mar 6, 2010

in a tab-delimited file, such as:

Code:
111aIab
222bIIbc

[code]...

View 3 Replies View Related

General :: Deleting A Specific Line Which Contains 2 Patterns?

Apr 7, 2011

i have a problem about deleting a line from a text file which contains two specific patterns. i am using "sed -i "/$name/ d" peop.txt" but i must use one more variable which is surname.

"
burak:ak:3242:2342:dsa@a.com
gokhan:an:432:4234:da@a.com
"

and this is the code of text file. and the second question when i use "/$name/ d" it deletes not only the names which are macthing with $name but also all words that contain $name. so how can i fix these problems_?

View 2 Replies View Related

Programming :: Count The Number Of Slashes In Each Line?

Jan 18, 2010

I have a file with lines that look like this:

Dev/7_Texas2004/4_Caves/page.htm
Dev/7_Texas2004/5_SanMarcos/page.htm
Dev/7_Texas2004/6_Austin/page.htm

And I'm trying to count the number of slashes in each line. I figured (with my limited knowledge of bash) that the best thing to use would be sed. So I ran this to print "not /": sed '!s////g' file # and eventually adding " | wc -m" to it. and I got the same result as if I ran cat, no modification at all:

[Code]...

View 7 Replies View Related

General :: Mapping With Series From Master File And Calculate Count?

Sep 7, 2010

My shell script is calculating the count of each shortcode series wise whose sample output is as follows:

Code:

56882
9124 1
9172 1
9173 4

[code]....

View 1 Replies View Related

General :: Count The Number Of Lines Inside A File And Put The Output Into A Variable?

Feb 1, 2011

i 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 Related

General :: Showing Date On Command Prompt Line?

Mar 1, 2011

i need to add the date of the root of the command prompt line, i can get it show to the date for any user how do i just do it for root? and i added it to the .bash_profile file

export PS1='[`date +%D` u@h W]$ '

View 3 Replies View Related

Programming :: Text On A Specific Line At The End Of A Line?

Jul 26, 2010

I'm trying to add text to a file for a specific group of users, I'll need to do examples as I can't think of an easy way of explaining, my file is like this:

Code:

users{
user1
user2

[code]....

At the present my code lists all the available groups, how would I add a user to a specified group? (e.g add "members user3") to the end of group 1 for example. So the code ends up like this

Code:

members user2,user3

View 14 Replies View Related

OpenSUSE :: Count Lines In Multiple Text Files From Command Line?

Apr 27, 2010

I want to (from the command line) be able to counte lines in a bunch of files of a specific type in a folder and all its sub-folders. How would I do this?

View 1 Replies View Related

General :: Command Line To Check For A Specific Email - By Subject - On An SSL Secured IMAP Server?

Feb 1, 2011

Anyone know a simple command line to check for a specific email - by subject - on an SSL secured IMAP server?

View 2 Replies View Related

General :: Scripting - Feed An Input File Into An If Statement Line-by-line

Dec 23, 2009

I am trying to write a script that takes an input file ($FileName) and an intermediate file ($FileName.info) and removes lines from $FileName if the value in $2 of $FileName.info is <75.

I can't figure out how to feed only one line of the .info file to the if statement at a time so that it will perceive it as an integer instead of a list.

The error I am getting now is ./script.sh: line 6: [: : integer expression expected

Sample input $FileName

Code:

Code:

Code:

Script so far:

Code:

View 10 Replies View Related

General :: Parse A File And Print Each Line That Ends With Matching Pattern (if The Next Line Is Blank)

Aug 2, 2010

I've written a script to parse a file and print each line that ends with matching pattern, if the next line is blank. The pattern lines are the result of md5sum $i|sed 's/path///g' so that only md5 and filename appear. Here's what I'm using.

Quote:
for fline in `sed -n '/.*.ext$/p' file1`
do
if [ "`sed -n -e '/'"$fline"'/ {n; p;}' file1`" == "" ]
then
echo ""$fline" has no info" >>file2
fi
done
[Code]....

View 4 Replies View Related

General :: Command Line Way To View A Line Of A File With Context?

Feb 24, 2011

I'd like show a certain line or lines of a file with context, kind of like a unified diff, on the command line in Linux:

$ (something) -l 154 stuff.py
150: def foo(bar):
151: """

[code]....

View 5 Replies View Related

General :: Appending To The Current Line In A File Instead Of Creating A New Line?

Apr 1, 2011

I am combining data from a couple different input files and creating an output file in a specific format. I notice that if I use the >> operator, information gets appended to a new line in my output file. This is useful, but if I'd like to append onto the CURRENT line, is there an easy way to do this? I've been googling around and see lots of complicated answers, nothing that suggests to me an easy way to do this. For example, if my output file looks like this:

b1a:] cat test
hello my name is
b1a:]

and I'd simply like to append "Bob", how can I do it? If I use

b1a:] echo Bob >> test
b1a:] cat test
b1a:] hello my name is
Bob
b1a:]

So what I would prefer is some command that would create the result:

hello my name is Bob

View 14 Replies View Related

General :: Find Folders With ONLY One Specific File In And Delete File And Folde

Oct 21, 2009

Many folders within a subdirectory some of which have lots of data in and some of which have only one specific file called produkt.fil inside.I need a command to find and delete those folders that contain ONLY the file produkt.fil - if other files exist (doesnt matter what they are) then they should be left alone. Note: produkt.fil exists in all of the folders always.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved