Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • This is called a command substitution and it's really handy. tldp.org/LDP/abs/html/commandsub.html#CSPARENS Commented Jan 26, 2015 at 5:45
  • Thanks! It works. Is there away to quickly prepend a prefix a_ to ALL four files? I tried echo "a_$(ls | tail -n 4)", but it only prepends the first file. Commented Jan 26, 2015 at 6:29
  • @SibbsGambling My approach is not suitable for that but John1024's answer can easily be adapted to that. Commented Jan 26, 2015 at 6:32
  • 5
    In general parsing ls output is considered bad form because it typically fails horribly on file names that contain not only spaces, but also tabs, newlines, or other valid but "difficult" characters. Commented Jan 26, 2015 at 6:56
  • 2
    @HaukeLaging Even if it is currently not a problem (because I don't have "complicated" firenames in my directory), I might have in 2 years, and suddenly things fall on my feet... Commented Jan 26, 2015 at 11:05