Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Help with bash script

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
germany1517 germany1517 is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 16 October 2017, 9:48 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Help with bash script

I wrote a script using the command:

Code:
echo -e  ` grep -e "ATOM" $1 | cut -c7-11,31-54 `

the problem I am having is that the output in the script does not list the lines I am cutting, instead it places one next to the other in succession. How do I get the script to list the lines? I am new to unix so I am not sure what command to use

Moderator's Comments:
Help with bash script Please use CODE tags as required by forum rules!

Last edited by RudiC; 1 Week Ago at 01:31 PM.. Reason: Added CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 October 2017, 5:17 PM EDT
Location: Aachen, Germany
Posts: 11,483
Thanks: 310
Thanked 3,561 Times in 3,276 Posts
Welcome to the forum.

Not sure I understand. Please post input and output samples.
Sponsored Links
    #3  
Old Unix and Linux 1 Week Ago
germany1517 germany1517 is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 16 October 2017, 9:48 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks.
My script reads

Code:
if [ -z $1 ] 
then echo ""
else echo `grep -e "ATOM" $1 | cut -c7-11,31-54 `
fi

the input is the script with a filename
the output is:

Code:
23 14.267 10.895 0.527 24 13.400 10.078 -0.311 25 12.709 8.924 0.402 26 11.490 8.813 0.312

but the output is supposed to list them like this:

Code:
23 14.267 10.895 0.527 
24 13.400 10.078 -0.311 
25 12.709 8.924 0.402 
26 11.490 8.813 0.312

I am trying to crate a script that can open any pdb file and grep any rows with the word ATOM and just view certain columns in the output

Last edited by vgersh99; 1 Week Ago at 01:56 PM.. Reason: code tags, please!
    #4  
Old Unix and Linux 1 Week Ago
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 October 2017, 5:17 PM EDT
Location: Aachen, Germany
Posts: 11,483
Thanks: 310
Thanked 3,561 Times in 3,276 Posts
Input would have been the contents of the file whose name goes into $1 so people can see on what data your command operates.

Howsoever, wildly guessing, I suspect the shell's behaviour to replace all contiguous whitespace in an unquoted text by one single space to be the culprit. Try double quoting the "command substitution".

BTW, the backticks `...` in your "command substitution" are deprecated; use $(...).
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Make a password protected bash script resist/refuse “bash -x” when the password is given frad Shell Programming and Scripting 7 12-09-2013 12:36 PM
Im new to bash scriping and i found this expression on a bash script what does this mean. kevin298 UNIX for Dummies Questions & Answers 1 10-26-2012 07:04 PM
Bash Script: modify bash LibRid Shell Programming and Scripting 9 10-25-2010 06:17 PM
how to make your bash script run on a machine with csh and bash npatwardhan Shell Programming and Scripting 3 11-19-2008 03:17 AM
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 12:25 PM



All times are GMT -4. The time now is 10:28 PM.