Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9158965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:22:39+00:00 2026-06-17T13:22:39+00:00

I’m trying to: Taking a file/directory listing, and replacing all spaces >1 (NOT \t)

  • 0

I’m trying to:

  • Taking a file/directory listing, and replacing all spaces >1 (NOT \t) with ‘#’ for all files modified within the last 30 minutes.

Example output of: find / -mmin -30 -ls

310116371    0 -r--r--r--   1 root     root            0 Jan 14 0814 /proc/4732/wchan
310116373    0 -r--r--r--   1 root     root            0 Jan 14 0814 /proc/4732/schedstat
310116374    0 -r--r--r--   1 root     root            0 Jan 14 0814 /proc/4732/cpuset
310116383    0 -r--r--r--   1 root     root            0 Jan 14 0814 /proc/4732/oom_score
310116384    0 -rw-r--r--   1 root     root            0 Jan 14 0814 /proc/4732/oom_adj
310116382    0 -rw-r--r--   1 root     root            0 Jan 14 0814 /proc/4732/loginuid
310116416    0 -r--------   1 root     root            0 Jan 14 0814 /proc/4732/limits
310116418    0 -r--r--r--   1 root     root            0 Jan 14 0814 /proc/4732/io

What I want:

310116371#0#-r--r--r--#1#root#root#0#Jan 14 0814#/proc/4732/wchan

Specifically, I want to use {awk, sed, tr} to replace spaces where the amount of space is greater than 1. The only problem is, there is a single space after the timestamp arg for the directory listing…

Is there a computational method which exists today which can to this?

  • Log file being parsed consists of ~26k entries
  • Output being pasted into an .XLS file

What I’ve tried:

find / -mmin -5 -ls |  awk '{gsub(/s+/,"#",$0); print;}'
find / -mmin -5 -ls |  awk '{gsub(/[' ']+/,"#")}1'
find / -mmin -5 -ls |  awk '{gsub(/["  "]+/,"#")}1'
find / -mmin -5 -ls | sed "s/^ *//;s/ *$//;s/ \{1,\}/#/g"
find / -mmin -5 -ls |  awk -D '{gsub([ +],"#",$0); print;}' 
find / -mmin -5 -ls |  awk '{gsub(/\t/,"#",$0); print;}'

The problem:
– The output of find / -mmin -5 -ls is not {tab, comma} delimited by default


Any suggestions about where am I going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:22:41+00:00Added an answer on June 17, 2026 at 1:22 pm

    This does the trick for me awk 'gsub(/\s+/,"#")':

    $ awk 'gsub(/\s+/,"#")' file
    310116371#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/wchan
    310116373#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/schedstat
    310116374#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/cpuset
    310116383#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/oom_score
    310116384#0#-rw-r--r--#1#root#root#0#Jan#14#0814#/proc/4732/oom_adj
    310116382#0#-rw-r--r--#1#root#root#0#Jan#14#0814#/proc/4732/loginuid
    310116416#0#-r--------#1#root#root#0#Jan#14#0814#/proc/4732/limits
    310116418#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/io
    

    Or awk 'gsub(/\s{2,}/,"#")' for:

    Specifically, I want to use {awk, sed, tr} to replace spaces where the
    amount of space is greater than 1 (so, I can preserve the timestamp
    arg)

    $ awk 'gsub(/\s{2,}/,"#")' file
    310116371#0 -r--r--r--#1 root#root#0 Jan 14 0814 /proc/4732/wchan
    310116373#0 -r--r--r--#1 root#root#0 Jan 14 0814 /proc/4732/schedstat
    310116374#0 -r--r--r--#1 root#root#0 Jan 14 0814 /proc/4732/cpuset
    310116383#0 -r--r--r--#1 root#root#0 Jan 14 0814 /proc/4732/oom_score
    310116384#0 -rw-r--r--#1 root#root#0 Jan 14 0814 /proc/4732/oom_adj
    310116382#0 -rw-r--r--#1 root#root#0 Jan 14 0814 /proc/4732/loginuid
    310116416#0 -r--------#1 root#root#0 Jan 14 0814 /proc/4732/limits
    310116418#0 -r--r--r--#1 root#root#0 Jan 14 0814 /proc/4732/io
    
    # Single spacing
    $ awk 'gsub(/\s{2,}/," ")' file
    310116371 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/wchan
    310116373 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/schedstat
    310116374 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/cpuset
    310116383 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/oom_score
    310116384 0 -rw-r--r-- 1 root root 0 Jan 14 0814 /proc/4732/oom_adj
    310116382 0 -rw-r--r-- 1 root root 0 Jan 14 0814 /proc/4732/loginuid
    310116416 0 -r-------- 1 root root 0 Jan 14 0814 /proc/4732/limits
    310116418 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/io
    

    Edit:

    How about just setting the OFS variable:

    # Hash seperated
    $ awk 'BEGIN{OFS="#"}{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}' file
    310116371#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/wchan
    310116373#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/schedstat
    310116374#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/cpuset
    310116383#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/oom_score
    310116384#0#-rw-r--r--#1#root#root#0#Jan#14#0814#/proc/4732/oom_adj
    310116382#0#-rw-r--r--#1#root#root#0#Jan#14#0814#/proc/4732/loginuid
    310116416#0#-r--------#1#root#root#0#Jan#14#0814#/proc/4732/limits
    310116418#0#-r--r--r--#1#root#root#0#Jan#14#0814#/proc/4732/io
    
    # Hash sperated accounting for the spaces in the date
    $ awk 'BEGIN{OFS="#"}{print $1,$2,$3,$4,$5,$6,$7,$8" "$9" "$10,$11}' file
    310116371#0#-r--r--r--#1#root#root#0#Jan 14 0814#/proc/4732/wchan
    310116373#0#-r--r--r--#1#root#root#0#Jan 14 0814#/proc/4732/schedstat
    310116374#0#-r--r--r--#1#root#root#0#Jan 14 0814#/proc/4732/cpuset
    310116383#0#-r--r--r--#1#root#root#0#Jan 14 0814#/proc/4732/oom_score
    310116384#0#-rw-r--r--#1#root#root#0#Jan 14 0814#/proc/4732/oom_adj
    310116382#0#-rw-r--r--#1#root#root#0#Jan 14 0814#/proc/4732/loginuid
    310116416#0#-r--------#1#root#root#0#Jan 14 0814#/proc/4732/limits
    310116418#0#-r--r--r--#1#root#root#0#Jan 14 0814#/proc/4732/io
    
    # Single space sperated 
    $ awk 'BEGIN{OFS=" "}{print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}' file
    310116371 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/wchan
    310116373 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/schedstat
    310116374 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/cpuset
    310116383 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/oom_score
    310116384 0 -rw-r--r-- 1 root root 0 Jan 14 0814 /proc/4732/oom_adj
    310116382 0 -rw-r--r-- 1 root root 0 Jan 14 0814 /proc/4732/loginuid
    310116416 0 -r-------- 1 root root 0 Jan 14 0814 /proc/4732/limits
    310116418 0 -r--r--r-- 1 root root 0 Jan 14 0814 /proc/4732/io
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to render a haml file in a javascript response like so:
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.