Find the answer to your Linux question:
Results 1 to 2 of 2
Hi friends, The method of "alias " is GREAT. I have tried to make a custom command to know file size in MB I tried this Code: alias lsmb='ls -l ...
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    1

    alias error

    Hi friends,

    The method of "alias " is GREAT.
    I have tried to make a custom command to know file size in MB

    I tried this

    Code:
    alias lsmb='ls -l | awk '{printf "%s %i %s %s %.3fMB %s %i %s %s\n", $1,$2,$3,$4,$5/1024000,$6,$7,$8,$9}' '
    and when I did
    Code:
    source .bashrc
    it shows me error
    Code:
    bash: alias: %s %i %s %s %.3fMB %s %i %s %s\n,: not found
    bash: alias: ,,,,/1024000,,,,}: not found
    I guess the error is due to the awk and single quotes

    Any idea how to do it ??

  2. #2
    Linux Enthusiast Bemk's Avatar
    Join Date
    Sep 2008
    Location
    Oosterhout-NB, Netherlands
    Posts
    522
    Code:
    alias lsmb="ls -l | awk '{printf "%s %i %s %s %.3fMB %s %i %s %s\n", $1,$2,$3,$4,$5/1024000,$6,$7,$8,$9}' "
    Here I replaced the outer quotation marks in to double marks " which works well in HTML (haven't tried here, but I hope it is similar)

    Code:
    alias lsmb='ls -l | awk\ '{printf "%s %i %s %s %.3fMB %s %i %s %s\n", $1,$2,$3,$4,$5/1024000,$6,$7,$8,$9}\' '
    Here is the \ in front of the quotation mark saying it shouldn't end the string there, but include the quotation mark into the string.

    Hope either of them work, as I haven't tested it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...