Bash script with text and wc


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash script with text and wc
# 1  
Old 03-09-2010
Bash script with text and wc

Hi!
I´m all new to Unix and scripts, I´ve tried to write a script for wc with text so the output looks better, can anyone help me please?
I want it like this example:

>textWc file #<scriptname> <file to to run script on>
File: file

Rows: 7

Words: 56

Signs: 1312

>
# 2  
Old 03-09-2010
If this is a homework assignment, please read the rules!
# 3  
Old 03-09-2010
I think signs means,you meant characters.You run the following script to do it.

Code:
if [ $# -lt 1 -o $# -gt 1 ];then
echo "<Scriptname> <file-to-run>"
exit 1
fi

rows=`wc -l $1 | cut -d ' ' -f 1 `
words=`wc -w $1| cut -d ' ' -f 1 `
characters=`wc -c $1| cut -d ' ' -f 1 `

echo -e "Filename:$1\n"

echo -e "Rows:$rows\n"

echo -e "Words:$words\n"

echo -e "Signs:$characters\n"

# 4  
Old 03-09-2010
Its not a homework assignment!

I´ve new to Linux and installed Ubuntu one week ago, I`m just trying to make nicer outputs, I wrote a script on my own, a welcomescript and a datescript, so now one for wc too.

Relax man!

---------- Post updated at 07:56 AM ---------- Previous update was at 07:55 AM ----------

Thanks to user vivekraj!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

BASH script to read external file to perform text replacements?

Hi all, I have a moderate size (300 lines) BASH Shell script that performs various tasks on different source reports (CSV files). One of the tasks that it performs, is to use SED to replace 'non-conforming' titles with conformant ones. For example "How to format a RAW Report" needs to become... (3 Replies)
Discussion started by: richardsantink
3 Replies

2. Shell Programming and Scripting

Text manipulation with sed/awk in a bash script

Guys, I have a variable in a script that I want to transform to into something else Im hoping you guys can help. It doesn't have to use sed/awk but I figured these would be the simplest. DATE=20160120 I'd like to transform $DATE into "01-20-16" and move it into a new variable called... (8 Replies)
Discussion started by: dendenyc
8 Replies

3. Shell Programming and Scripting

Bash script - printing range of lines from text file

I'm working on a new exercise that calls for a script that will take in two arguments on the command line (representing the range of line numbers) and will subsequently print those lines from a a specified file. Command line would look like this: ./lines_script.bash 5 15 <file.txt. The script would... (8 Replies)
Discussion started by: ksmarine1980
8 Replies

4. Shell Programming and Scripting

Bash script - coloring reg. expressions in text

Hi all, is there anyone good at bash who will help me? I need to use syntax ${string/pattern/replacement} The problematic part where I am stuck is: #!bin/bash text="A cat is on a mat." exp="cat" newexp="SOMECODEcatSOMECODE" newtext=${${text}/${exp}/${newexp}} == > ERROR "wrong... (4 Replies)
Discussion started by: JohnnyM77
4 Replies

5. Shell Programming and Scripting

Bash Script Help...search then read from file: change text and pipe back...

Hello, I am trying to make a bash script that can pull data from a file and then change one part of said data. I want to search by username and pull the full line. That way there is a way to replace just one part of that line then return it back to the file. My Data is stored like: ... (1 Reply)
Discussion started by: serverfull
1 Replies

6. Shell Programming and Scripting

Difficult problem: Complex text file manipulation in bash script.

I don't know if this is a big issue or not, but I'm having difficulties. I apoligize for the upcoming essay :o. I'm writing a script, similar to a paint program that edits images, but in the form of ANSI block characters. The program so far is working. I managed to save the image into a file,... (14 Replies)
Discussion started by: tinman47
14 Replies

7. Shell Programming and Scripting

Bash shell script that inserts a text data file into an HTML table

hi , i need to create a bash shell script that insert a text data file into an html made table, this table output has to mailed.I am new to shell scripting and have a very minimum idea of shell scripting. please help. (9 Replies)
Discussion started by: intern123
9 Replies

8. UNIX for Dummies Questions & Answers

BASH script that sends text message or email

Hi, I have a BASH shell script that batch processes data. I often start this script before I leave to go home for the day, and leave it processing over night. It has come to my attention that it would be very useful for me to add the capability of making the script notify me about certain things... (2 Replies)
Discussion started by: msb65
2 Replies

9. Shell Programming and Scripting

Bash Script - Removing Year and Text from File Name

Hi, I have files with names in the following naming pattern, Name.of.moviemoretext-moretext.mov or Name of moviemoretext-moretext.mov And I would like to delete the and moretext-moretext leaving just the Name of movie. The Name of movie will always be different and the year will... (4 Replies)
Discussion started by: Monkey Dean
4 Replies

10. Shell Programming and Scripting

Bash script to delete folder based on text file information

I have been working on a script to list all the name's of a subfolder in a text file then edit that text file and then delete the subfolder base on the edited text file so far I have been able to do every thing I just talked about but can't figure out how to delete the subfolers base on a text file... (8 Replies)
Discussion started by: bone11409
8 Replies
Login or Register to Ask a Question