Issue when printing filename through cygwin using a variable with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue when printing filename through cygwin using a variable with awk
# 1  
Old 06-17-2015
Issue when printing filename through cygwin using a variable with awk

Hi,

If i were to do this an print out the file, it will show as it is in the command

Code:
$ awk '/Privilege Use/ {P=0} /Object Access/ {P=1} P' AdvancedAudit.txt
Object Access
  File System                             No Auditing
  Registry                                No Auditing
  Kernel Object                           No Auditing
  SAM                                     No Auditing
  Certification Services                  No Auditing
  Application Generated                   No Auditing
  Handle Manipulation                     No Auditing
  File Share                              No Auditing
  Filtering Platform Packet Drop          No Auditing
  Filtering Platform Connection           No Auditing
  Other Object Access Events              No Auditing
  Detailed File Share                     No Auditing
  Removable Storage                       No Auditing
  Central Policy Staging                  No Auditing

However if i were to store the awk in a variable and cat it later it will seems to execute the command. My expected output is the above mentioned.

Code:
objectaccess=`awk '/Privilege Use/ {P=0} /Object Access/ {P=1} P' AdvancedAudit.txt`
cat $objectaccess
cat: Object: No such file or directory
cat: Access: No such file or directory
cat: File: No such file or directory
cat: System: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Registry: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Kernel: No such file or directory
cat: Object: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: SAM: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Certification: No such file or directory
cat: Services: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Application: No such file or directory
cat: Generated: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Handle: No such file or directory
cat: Manipulation: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: File: No such file or directory
cat: Share: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Filtering: No such file or directory
cat: Platform: No such file or directory
cat: Packet: No such file or directory
cat: Drop: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Filtering: No such file or directory
cat: Platform: No such file or directory
cat: Connection: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Other: No such file or directory
cat: Object: No such file or directory
cat: Access: No such file or directory
cat: Events: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Detailed: No such file or directory
cat: File: No such file or directory
cat: Share: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Removable: No such file or directory
cat: Storage: No such file or directory
cat: No: No such file or directory
cat: Auditing: No such file or directory
cat: Central: No such file or directory
cat: Policy: No such file or directory
cat: Staging: No such file or directory
cat: No: No such file or directory
: No such file or directory

---------- Post updated at 09:30 PM ---------- Previous update was at 09:24 PM ----------
# 2  
Old 06-17-2015
Substitute cat for echo and see the difference.
Code:
echo $objectaccess

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

My awk executable is not printing FILENAME...: why?

Hello, there! I am running an executable awk script with 'source.awk input_file' and found that when I need to print FILENAME, or ENVIRON or even FNR nothing happens ... However, if I run it with 'awk -f source.awk input_file', then those variables are printed... What is the reason for that... (1 Reply)
Discussion started by: fbird3
1 Replies

2. Shell Programming and Scripting

My awk executable is not printing FILENAME...: why?

Hello, there! I am running an executable awk script with 'source.awk input_file' and found that when I need to print FILENAME, or ENVIRON or even FNR nothing happens ... However, if I run it with 'awk -f source.awk input_file', then those variables are printed... What is the reason for that... (6 Replies)
Discussion started by: fbird3
6 Replies

3. Shell Programming and Scripting

awk code to inspect variable before printing

i have a unique scenario id like help with. im currently running this command and it does what i want: printf '%s\n' "${RawContent}" | awk '/## Beginning Stages ##/,/## Ending Stages ##/' | awk '!/^#.*\!|^#\!|DefaultError/' Can this be shortened? I'm looking for something portable as... (8 Replies)
Discussion started by: SkySmart
8 Replies

4. Shell Programming and Scripting

[awk] printing value of a variable assignment from a file

Heyas Me try to print only the value of a (specific) variable assignment from a file. What i get (1): :) tui $ bin/tui-conf-get ~/.tui_rc TUI_THEME dot-blue "" "$TUI_DIR_INSTALL_ROOT/usr" "$TUI_DIR_INSTALL_ROOT/etc/tui" "$TUI_PREFIX/share/doc/tui" "$TUI_PREFIX/share/tui"... (2 Replies)
Discussion started by: sea
2 Replies

5. Shell Programming and Scripting

Call a awk script with variable and input filename

HI, MY question is a very simple one: if i want to call an awk script with the input file name and also pass a variable value , then how to do it. #>awk -f my_script.awk -v variable=value my_inputfile.txt I can't do it like this. throws error: awk: my_script.awk:18:... (0 Replies)
Discussion started by: Onkar Banerjee
0 Replies

6. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

7. Homework & Coursework Questions

problem with printing out variable in awk

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: couldn't print out stored variable in awk 2. Relevant commands, code, scripts, algorithms: i have in a... (5 Replies)
Discussion started by: ymc1g11
5 Replies

8. Shell Programming and Scripting

Printing a variable column using awk

Hi everyone, Ok here's the scenario. I have a control file like this. component1,file1,file2,file3,file4,file5 component2,file1,file2,file3,file4,file5I want to do a while loop here to read all files for each component. file_count=2 while ] do file_name=`cat list.txt | grep... (2 Replies)
Discussion started by: The Gamemaster
2 Replies

9. Shell Programming and Scripting

Awk Issues - Not printing the 10th Variable.

All, I am attempting to print the tenth ($COPY2) varaibales into one file. But i am finding that all variables are being outputted except for $10. Can someone help!!!! Code Below ---------- echo $SERVER $IMAGE $IMAGEDAY $IMAGEMONTH $IMAGEYEAR $COPY1 $EXPIREDAY $EXPIREMONTH... (1 Reply)
Discussion started by: Junes
1 Replies

10. UNIX for Dummies Questions & Answers

AWK Filename as variable

Need some help. I need to load data into some Oracle tables and one of the pieces of data that I need to load is the filename. This filename is distinct every single time. Basically the last 6 characters will be different with no pattern. ex. testfile_041504_003567 To load the filename... (4 Replies)
Discussion started by: firkus
4 Replies
Login or Register to Ask a Question