Cat Help needed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cat Help needed
# 1  
Old 10-10-2011
Cat Help needed

Hi,
I am unable to use a basic script in cygwin. Please help me out.

Script used :

Code:
#!/bin/bash
echo "Lucent MSC1" 
echo "===========" 
echo "Orig_MSCID Summary Top 10" 
cat k1.txt | grep -i orig_mscid | sort | uniq -c  
echo "Hourly Summary" 
cat k1.txt | grep "#" | cut -c 10-11 | uniq -c 
echo Bye

Error :

Code:
$ ./TLDN.txt
Lucent MSC1
===========
Orig_MSCID Summary Top 10
: No such file or directory
Hourly Summary
: No such file or directory
Bye

However the file exist in the folder.

Code:
$ pwd
/home/sgupt023

sgupt023@sgupt023-c420 ~
$ cd 09oct

sgupt023@sgupt023-c420 ~/09oct
$ ls
2.txt  4.txt  5.txt  6.txt  K1.txt  K2.txt  TLDN.TXT  a.txt  cgrep

# 2  
Old 10-10-2011
change the filename to a full file specification, example: /home/sgupt023/k1.txt,
or add a line in the very top of the script
Code:
cd /home/sgutpt023

# 3  
Old 10-10-2011
Thanks. Tried both the solutions. But still not working.Smilie

Executing the script as individual line works.

Code:
sgupt023@sgupt023-c420 ~/09oct
$ ./TLDN.TXT
: No such file or directoryme/sgupt023
Lucent MSC1
===========
Orig_MSCID Summary Top 10
: No such file or directory
Hourly Summary
: No such file or directory
Bye

sgupt023@sgupt023-c420 ~/09oct
$ pwd
/home/sgupt023/09oct


Last edited by pludi; 10-10-2011 at 10:06 AM..
# 4  
Old 10-10-2011
In your script I see k1.txt and that directory shows K1.txt. Not sure about cygwin but usually unix/linux is case sensitive.
# 5  
Old 10-10-2011
# 6  
Old 10-10-2011
Tried both K1 and k1 still not working. Please help Smilie
# 7  
Old 10-10-2011
Are you sure you are in the correct directory when you execute your script? It looks like you are sometimes calling the script with .TXT and sometimes with .txt. I would try making all filenames lowercase and making them all lowercase in your script as well.

Also, when you tried the full filename specification, did you use "/home/sgupt023/k1.txt" or "/home/sgupt023/09oct/k1.txt"? Looks like the files are in the 09oct directory, so the latter is the correct one to use.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cat with << >>

Hi, When I was analyzing the code I got below line. cat - << 'EOF' >> ${FILE PATH} I surfed net to understand but I couldn't get what is about. Please help me out. (2 Replies)
Discussion started by: stew
2 Replies

2. Shell Programming and Scripting

cat question

hello! why this works? cd /home/user cat * | ecasound -i stdin -o jack and this doesn't? cd /home/user/somedirectory cat * | ecasound -i stdin -o jack somedirectory are full with exe files which are the best source for this sort of noise thing (10 Replies)
Discussion started by: karlhungus
10 Replies

3. UNIX for Dummies Questions & Answers

Question regarding Cat

Can we concatenate say, I have a few files prefixing with 2009... So now i want all the 2009 files into one single file.. Can this be achieved???? (4 Replies)
Discussion started by: saggiboy10
4 Replies

4. UNIX for Dummies Questions & Answers

for cat help

Hi there, I have the following problem. I have a csv file which looks like 'AGI,ABJ,Y,Y,Y,None,EQUATION,ANY,ANY,None,' 'AGI,ABJ,Y,Y,Y,None,EQUATION HEAVY,ANY,ANY,None,' 'AGI,ABJ,Y,Y,Y,None,VARIATION,ANY,ANY,None,' but I do this for ab in $(cat test.csv); do echo $ab; done in the... (4 Replies)
Discussion started by: sickboy
4 Replies

5. Shell Programming and Scripting

Cat command help

I want to concatenate 100 files to one file and append file name in each record to find out which file it came from for a in $(<shal_group) do cat $a >> bigoutput.group The above code put all files in one file but i want file name appended to each file Record should be like this... (3 Replies)
Discussion started by: pinnacle
3 Replies

6. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

7. Shell Programming and Scripting

for i in `cat myname.txt` && for y in `cat yourname.txt`

cat myname.txt John Doe I John Doe II John Doe III ----------------------------------------------------------------------- for i in `cat myname.txt` do echo This is my name: $i >> thi.is.my.name.txt done ----------------------------------------------------------------------- cat... (1 Reply)
Discussion started by: danimad
1 Replies

8. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

9. UNIX for Dummies Questions & Answers

How to cat file

I want to cat a file with only show the line contain '/bin/bash' but don't show the line contain 'load' (don't show if the line contain 'load' and '/bin/bash' together), how to type in the command? thk a lot! (2 Replies)
Discussion started by: zp523444
2 Replies
Login or Register to Ask a Question